Commit Graph
161 Commits
Author SHA1 Message Date
José Valim 8930ea7598 Do not attempt to load modules that have not been required, closes #4900 2016-06-29 01:20:45 +01:00
José Valim abec905009 Use a more explicit pdict key 2016-06-04 16:47:00 +02:00
José Valim 2a1d3d6530 Keep the full list of modules being defined 2016-06-04 11:53:40 +02:00
Andrea Leopardi 26a4fc5788 Add support for the @optional_callbacks behaviour attribute (#4705) 2016-05-28 13:19:12 +02:00
José Valim 793e657eaa Store function definitions and clauses in the same table 2016-05-19 13:23:19 +02:00
eksperimental 4ceb41e71b Formmating: Add white space around vertical bar (#4507) 2016-04-25 00:55:49 +02:00
José Valim b6dc389f5e Improvements to the parallel compiler
In previous versions, when trying to compile a file and the file
depended on a module that was not yet compiled or was unavailable,
the parallel compiler would wait until the missing dependency shows
up. In case it did not, the compiler would "release" the file being
compiled, disabling any further missing dependency resolution.

This lead to issues in code like the following:

    Code.ensure_compiled(SomeModuleThatWontBeAvailable)
    %SomeStructFromMyProject{}

Because `SomeModuleThatWontBeAvailable` would never be available,
the file above would block until released. When released, the
parallel compiler would disable further lookups for that file,
meaning we would no longer wait for missing dependencies when we
attempt to load the struct.

In the majorify of cases, the struct would already be available,
which meant compilation would work. But if the file that defined
the struct was also blocked by the compiler (and consequently
released), compilation would be non-deterministic.

This patch solves the issue by removing the "release" behaviour
from the compiler. If a dependency is not available, we will
notify the file of such and move on, with the parallel compiler
still enabled. In order to guarantee this works without
introducing deadlocks, the parallel compiler now also knows which
module is being defined by a given file, building a graph and
solving dependencies from the leaves. In case it is a cyclic
graph, we will raise that a deadlock was found.

Closes #4294
Closes #4055
2016-02-13 14:15:18 +01:00
José Valim 92b803b835 Support disabling autoload after compilation
Useful for delaying loading of modules that may depend
on NIFs until necessary.
2016-01-25 00:11:52 +01:00
José Valim 95ad8eb58d Include where the module being redefined is currently loaded from 2016-01-21 13:24:41 +01:00
Alexei Sholik 1703066f60 Update the spec for the generated __info__/1 function to please Dialyzer
Verify the spec's correctness with `mix dialyze --specdiffs` in a dummy
mix project.
2015-12-25 22:39:37 +02:00
Aleksei Magusev 19c40ec584 Favor local calls inside modules 2015-10-24 00:49:45 +02:00
José Valim d9a93c47ca Solve bootstrap issues with @doc 2015-10-14 18:25:20 +02:00
José Valim ab00a502bc Forward all info values to get_module_info 2015-08-31 21:03:52 +02:00
jisaacstone 2320097aa7 Line numbers for doctest errors. Fixes issue #3592
Note that this will change all line numbers retured by `Code.get_docs`.
2015-08-19 11:04:50 -07:00
José Valim ac5c72dbc7 Soft-deprecate Behaviour 2015-08-14 23:01:37 +02:00
Eric Entin 7aba0e0b52 @callback can now be used directly (without Behaviour). Add @macrocallback. 2015-08-14 14:29:34 +01:00
James Fish c9c34c2381 Support dialyzer attribute 2015-06-25 13:25:06 +01:00
Or Neeman babe8f7364 Support specs for unreachable private functions
Unreachable private functions are excluded during
compilation. As a result, if such a function had a `@spec`,
it would cause a `CompileError`. This commit fixes that by
also excluding any specs for unreachable private functions.

Closes #3144
2015-03-29 21:44:53 -06:00
eksperimental 61675c3ea8 Add space after comma: Format consistently 2015-03-17 22:55:27 +07:00
Aleksei Magusev 5f7984fa5b Store behaviour docs in the byte code 2015-03-13 11:26:48 +01:00
Aleksei Magusev 9705302b3a Make on_definition insertion more readable 2015-03-13 00:37:32 +01:00
José Valim 4469b746bc Explicitly pass allowed attributes to __info__ 2015-01-26 19:17:31 +01:00
José Valim 19868cd286 Merge pull request #2762 from fishcakez/undef_errors
Improve UndefinedFunctionError
2015-01-15 15:15:50 +01:00
José Valim a7dbfd1e82 Remove broken and unfixable delegate_locals_to implementation 2015-01-06 23:34:08 +01:00
José Valim 150a8a1dcd Fix bootstrap issues 2014-12-23 22:26:04 +01:00
José Valim 2935e7149a Ensure compilation does not leave random spurious data on failure
Prior to this patch, the parallel compiler could leave spurious
processes and the module definition could leave stale data
in the elixir_modules table.

The issue has been fixed by emitting the proper exit signals
and by using monitors.
2014-11-21 17:40:06 +01:00
José Valim 8de8a56223 Use unamed tables for module compilation
* We have created a main named table that keeps all module information

* We have reduced the amount of tables by storing internal, docs and
  attributes altogether and using table looks for retriving the relevant
  information

* At this moment, creating a module in Elixir defines three tables,
  one for data, another for functions and another for clauses
2014-10-17 13:51:19 +02:00
James Fish 8b8e7801a6 Improve UndefinedFunctionError
* Detect undefined errors for compiling modules
* Log undefined errors in Task's like other OTP processes
* Normalize undefined errors from OTP processes
2014-09-10 15:06:32 +01:00
José Valim 79fb40ab6a Correctly follow code specs when loading binaries
If we are compiling the module, we will load it with the
output of its beam file. If the module exists only in
memory, :code.which/1 will return `:in_memory`.

Closes #2533
2014-08-06 12:05:55 +02:00
José Valim 84010d4467 Ensure private functions are not exported, closes #2587 2014-07-29 11:22:19 +02:00
José Valim f5bf9d9659 Do not call handle_file_warning directly 2014-07-08 19:03:22 +02:00
José Valim 2865bd8653 Make elixir_errors API more strict and consider :file in meta 2014-07-08 18:54:40 +02:00
José Valim 4513b6965f Emit :file attribute on all nodes instead of a select few 2014-07-08 15:53:32 +02:00
José Valim 1dda1563da Ensure docs with no function raise warnings 2014-07-05 22:25:15 +02:00
José Valim 1bd0ca6dea Return explicit :ok from more functions 2014-07-05 13:43:52 +02:00
José Valim 8e1f7fddca Always return ok from tracking functions 2014-07-05 13:21:59 +02:00
James Fish 39cd4a6594 Fix unmatched returns dialyzer warnings 2014-07-04 02:45:16 +01:00
José Valim 595f9bb0b1 Improve poorly specified callbacks 2014-07-03 16:50:37 +02:00
José Valim 80b9879d0a Refactor how definitions are analyzed 2014-07-03 14:15:24 +02:00
José Valim c8a0158791 Add @external_resource attribute, closes #2455 2014-06-27 22:16:34 +02:00
Eric Meadows-Jönsson 587c83cbff Delay typespec compilation to after expansion 2014-06-18 19:49:57 +02:00
José Valim 2b3e53670e Provide Protocol.derive/3 2014-06-05 22:54:10 +02:00
José Valim 436f563ad3 Ensure variables do not leak on callbacks 2014-05-25 14:22:23 +02:00
José Valim 34c2da2c65 Initial work on @derive for structs 2014-05-25 01:43:58 +02:00
José Valim 3ab1db6740 Move Protocol consolidation up to the Protocol module 2014-05-24 18:28:48 +02:00
Alexei Sholik bc65fc0276 Preserve docs chunk during protocol consolidation 2014-05-24 03:45:30 +03:00
Alexei Sholik b1f0d3ed99 Add version tag to Elixir’s beam chunk
This will allow us to change the layout of the chunk in the future
2014-05-24 03:45:29 +03:00
Alexei Sholik 8a3f2cfc2f Remove :docs and :moduledoc clauses from the __info__ function
Instead, we keep the docs in a custom chunk within the .beam file;
this will allow us to lazily load them
2014-05-24 03:45:29 +03:00
José Valim 3d4877ffda Get rid of BitString module and bitstring conversions 2014-05-17 16:34:26 +02:00
Paul Schoenfelder a6392a8220 Add typespecs for builtins, __record__, and __struct__
Added typespecs for:

- __FILE__/1
- __MODULE__/1
- __info__/1
- __record__/1, __record__/2, __record__/3
- __struct__/0
2014-05-16 11:45:47 -05:00