Commit Graph
264 Commits
Author SHA1 Message Date
José Valim 9fb7c9f9ea Do not allow slashes in module names
Closes #11216.
2021-08-29 10:13:22 +02:00
José Valim 2e4f0fdbfa Add mix xref trace that shows all deps for a given file (#11184) 2021-08-17 18:04:15 +02:00
José Valim 739ad53fed Break Macro.Env apart (#11164)
Previously, the internal Elixir expansion pass worked directly on
Macro.Env. However, this poised an issue, if we want to track
more information in the pass, we ended up exposing it on
Macro.Env, making it larger, and potentially slowing down
operations such as __ENV__ serialization.

This commit refactors the expansion pass to work with two
structures, the Macro.Env struct and a #elixir_ex{} record.
2021-08-03 13:35:15 +02:00
José Valim 1ae07f7c0a Add {:on_module, bytecode, :none} to compilation tracers
See #11145.
2021-07-27 13:17:31 +02:00
José Valim a1c3af081e Ensure waiting is tracked across typespecs
The Elixir compiler spawns a separate process per file.
When a file has to wait on another module, Elixir tracks
in the compiler that the file is waiting.

However, every time a module is defined, the Elixir compiler
spawns a separate process to compile to .beam, and this
process may expand structs in the typespec. Since this
new process is no longer the original file process, Elixir
was not able to track its waiting time.

This PR address this issue by passing the original file_pid
to the .beam compiler process. Note though that, if we
change typespecs to be compiled in the original file process,
this change is no longer required, but at the moment there are
no plans to make such change.

Closes #11036.
2021-06-05 19:21:12 +02:00
José Valim f97137894f Assume Elixir is not started when accessing configs 2021-05-21 12:02:15 +02:00
José Valim 3fff1e9c35 Clean up shared parallel checker table 2021-05-09 09:08:39 +02:00
José Valim 2eb03e4a31 Reduce the amount of module map copies when compiling
Prior to this commit, compilation would copy the module map
(which is the map with the module definitions, attriubutes,
etc) multiple times. In particular, the module execution
process would pass it to the compiler. Then the module
execution process would send it to the parallel compiler
coordinator, which would pass it to the parallel checker
coordinator and then to each individual parallel checker.
That's four copies, which can be quite expensive since it
has the whole Elixir AST.

This commit makes it so it is copied only once. The map
is assembled inside the compiler process and then copied
to the checker process.

This has yielded good improvements in Elixir's test suite.

Before:

    Finished in 27.3 seconds (14.4s on load, 7.0s async, 5.8s sync)

After:

    Finished in 22.0 seconds (9.4s on load, 6.7s async, 5.8s sync)
2021-05-07 16:41:10 +02:00
José Valim 5ddd5f37bd Improve undefined function compilation errors 2021-04-18 08:58:20 +02:00
José Valim e79d32a8aa Use persistent term for tokenizer and bootstrap 2021-04-01 10:45:15 +02:00
José Valim c5373b965e All @dialyzer module attributes also work for functions 2021-03-11 21:42:19 +01:00
José Valim c537c39c52 Validate dialyzer attributes, closes #10534 2021-03-10 11:13:41 +01:00
José Valim 53bbbc50b4 Do not warn for attributes used in after_compile
Closes #10579.
2020-12-17 13:05:02 +01:00
José Valim aa78b32291 Allow @on_load to be private, closes #10438 2020-10-17 20:08:06 +02:00
Eksperimental 7dc2dd2e8e Rename struct attribute in defstruct (#10354)
Rename `@struct` to `@__struct__`.

Closes #10352
2020-09-20 20:26:25 +02:00
José Valim e3344123c2 Do not propagate tracers to dynamic definitions, closes #10271 2020-08-18 20:06:44 +02:00
José Valim e51cc8b88c Also track exports API via local deps 2020-06-25 15:09:14 +02:00
Ioannis Pinakoulakis 6666b7bb31 Typos on the erlang files (#10118) 2020-06-21 11:14:11 +02:00
Eric Meadows-Jönsson e8c49a446a Do not warn for functions generated by Erlang compiler (#9713) 2020-01-12 12:15:21 +01:00
José Valim 2b05b8dcf3 Use version metadata in Erlang pass 2019-11-16 02:45:55 +01:00
Eric Meadows-Jönsson b3e48bc1cb Track variable version globally (#9536)
Instead of incrementing the version for each variable individually we increment it globally for all variables. This means we can uniquely identify each variable assignment with only the version.
2019-11-15 17:18:39 +01:00
José Valim afa860ab4a Remove unecessary Erlang macro 2019-11-01 19:19:54 +01:00
José Valim 9529e528cc Move unused_vars to its own variable 2019-10-29 17:17:53 +01:00
Glauber Campinho 7dd86ec1f7 Execute callbacks on :elixir_compiler after all warnings are emitted (#9447)
Currently the callbacks on :elixir_compiler are called before the warnings of unused aliases and imports are emitted, causing the messages to not consumed during the compilation. This commit changes `:elixir_lexical.run/2` to `:elixir_lexical.run/3` splitting the callback in two, one during the execution to evaluate the forms and another to be called after all the warnings are emitted.

Fixes #9440
2019-10-26 10:58:28 +02:00
Eric Meadows-Jönsson c6da1cfaa8 Run checker on Code.require_file/1 (#9393)
Closes #9362.
2019-10-10 23:11:10 +02:00
José Valim fd49a67f34 Add defmodule tracing event 2019-10-07 16:12:52 -03:00
José Valim 99f504e9dc Use read-only naming for Module operations 2019-08-09 16:11:16 +02:00
Aleksei Matiushkin 9a959eac25 Make Module.open?/1 and family to match their docs (#9278)
* Make Module.open?/1 and family to match their docs.

* Cosmetics.

* Introduced internal not_closing state for modules.

It’s stored in a separate ETS and the last field of #elixir_code_server state to minimize impact.

* Use the same ETS for the state.
2019-08-09 15:43:43 +02:00
José Valim b08593b9d1 Add compiler tracing (#9247)
This feature allows IDEs and other tools wanting to
perform source code analysis to do so reliably without
a need to reimplement Elixir's compiler expansion and
without relying on Elixir's private APIs.

This commit also adds :parser_options to compiler
options, which allows developers to combine both options
to retrieve more accurate information, such as columns.
2019-08-02 13:35:12 +02:00
José Valim 6c5ad7b661 Clean up Macro.Env and hide private fields 2019-07-25 22:07:51 +02:00
José Valim cbc6029fec Store each compiler option directly in elixir_config, closes #9208 2019-07-18 17:13:10 +02:00
Allen Madsen dc24889fee Change :attributes to :warn_attributes for clarity (module bag table) (#9223) 2019-07-14 15:35:29 +02:00
Allen Madsen f2c63bf030 Add Module.has_attribute?/2 (#9200) 2019-07-09 17:21:04 +02:00
Eric Meadows-Jönsson 9b6ec7bae7 Move unreachable function check from xref to group pass (#9168) 2019-06-28 10:25:49 +02:00
José Valim 78ce6793e3 Store relative file in module definition (#9099)
Prior to this patch, we would always compute the relative
path to the current working directory (CWD), but this meant
consolidated protocols would always get a full path since
they are always outside of their current working directory.
We address this by also storing the relative path in the
definition.

Closes #9095
2019-05-31 09:01:02 +02:00
Victor Rodrigues 7e6bac3450 Do not allow defmodule with special atoms (#9032)
Fixes #9030
2019-05-10 20:47:36 +02:00
José Valim a3c5820d12 Properly track files instead of modules in mix integration with lexical tracker 2019-03-15 00:06:41 +01:00
Fernando Tapia Rico 1aeb445b40 Store overridable information more efficiently (#8799)
This is part of an ongoing effort to forbid overriding macros
with functions and vice-versa. New checks will require the
overridable information to be stored more efficiently.
2019-02-16 16:05:54 +01:00
José Valim 0e15f809bb Avoid race conditions on behaviour checks, closes #8568 2018-12-27 16:29:33 +01:00
José Valim 0c1df34645 Standardize more TODOs 2018-12-21 13:42:54 +01:00
Fernando Tapia Rico c190f09d5c Allow @type, @opaque, @typep, @spec, @callback, and @macrocallback to be used as module attributes (#8289)
Closes #8085
2018-10-18 22:45:13 +02:00
José Valim cd439540fc Revert wrong warning on parse_transforms removal 2018-09-07 10:04:57 -07:00
Michał Muskała d76f150274 Use scoped deterministic counters in AST expansion
Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
2018-08-04 12:56:01 +02:00
José Valim f2415dd06c Revert "Use deterministic counters in AST expansion"
Unfortunately it is common to have macros that invokes macros
from other modules, leading to mixed quoted expressions causing
the counters to be mixed.

We would need to scope the counters to the caller.

This reverts commit f04f46c49d.
2018-08-04 12:29:03 +02:00
Michał Muskała ffb931a5ac Fix all compiler warnings (#7992) 2018-07-27 16:42:24 +02:00
Fernando Tapia Rico 6d0f78d3bd Validate @on_load function in Elixir (#7973) 2018-07-26 16:57:35 +02:00
Michał Muskała f04f46c49d Use deterministic counters in AST expansion
When the module is being compiled, we use deterministic counters instead
of random ones. This should help with most cases of undeterministic
source code or .beam files.

Closes #7955
2018-07-25 00:10:02 +02:00
Fernando Tapia Rico ae15d1822f Check duplicated @on_load attributes (#7921) 2018-07-18 19:34:31 +02:00
José Valim 54cb02c240 Rely on Erlang/OTP normalization which is faster 2018-07-12 13:28:58 +02:00
José Valim 94f3d60a26 Hard deprecate previously deprecated APIs 2018-07-12 12:44:03 +02:00