Commit Graph
246 Commits
Author SHA1 Message Date
Eric Meadows-Jönsson 0e8873238d Do not warn for functions generated by Erlang compiler (#9713) 2020-01-12 15:42:54 +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
José Valim d33bac539c Allow :deprecated to be given as doc metadata 2018-07-11 11:01:57 +02:00
José Valim 32450a0fd9 Remove Code.get_docs/2 and streamline the new chunk generation 2018-07-05 10:31:23 +02:00
Glauber Campinho 4bc3527134 Consider if definition should be checked for @impl
Fixes #7617

Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
2018-05-10 23:05:40 +02:00
José Valim e28931fdaa Pass tracker destination forward to dynamicly defined modules 2018-05-02 12:18:50 +02:00
José Valim 49132ad6c1 Avoid race conditions with code evaluated in after_load callbacks 2018-03-31 10:08:53 +02:00
Nikola Jichev f963013036 Add Function module for introspecting functions (#7503)
Reason to add it is capturing functions when passing in module name,
function name and arity using variable, because the capture operator
can't handle them.

Done by delegating to `:erlang.make_fun(mod, f, arity)`, also exposed
some erlang functions for getting information for a function.
2018-03-28 11:52:00 +02:00
Michał Muskała 946455ec42 Validate @compile attribute in elixir (#7476)
* error on undefined inlined functions
* warn on parse transforms
2018-03-25 09:52:36 +02:00
José Valim ac1af198c8 Move accumulate attributes to a separate table (#7472)
We also speed up reading and writing of attributes via the @ macro.
2018-03-21 17:13:43 +01:00
José Valim a5a8ad3eaa Refactor how typespecs docs are stored 2018-03-20 18:03:02 +01:00
José Valim 0ce9ea6188 Keep specs, types and callbacks in the bag table
This avoids copying typespecs in and out of the table
every time there is a new entry.

We also make sure the Protocol module is only relying
on public APIs and not on inner typespec behaviour.
2018-03-20 18:03:02 +01:00
José Valim d297fe5195 Avoid full table traversals when building "deprecated" and "docs" chunk 2018-03-20 18:03:02 +01:00
José Valim eb2418d4b1 Remove locals tracker table
Instead we use the bag and set tables accordingly.
2018-03-20 18:03:02 +01:00
José Valim 8c85557346 Share Bag and Set tables across a module functionality
Previously we kept a Set table for attributes and a Bag table
for function definitions and clauses. This led to suboptimal
usage of ets tables.

With this commit, we start using both Bag and Set tables
to store function/macro definition information. In the next
commits we will continue generalizing the tables, storing
specs, docs and accumulated attributes in the Bag and keep
the remaining functionality in Set.
2018-03-20 10:30:37 +01:00
José Valim 054f9172fa Do not track @since attributes while bootstraping 2018-01-20 19:46:43 +01:00
José Valim 219c6cc867 Move unused_vars check to Elixir land
This gives us better control over when and how unused variables are printed.

As a result, we are able to emit unused variable warnings in situations
we could not before. This also opens up the way for us to remove a
dependency on erl_lint and track types information, which allows us to
speed up compilation times about 5% and allow us to emit more performant
code in some situations.
2018-01-20 19:45:48 +01:00
José Valim 113d2c69c9 Remove export_vars from Macro.Env 2018-01-20 19:42:08 +01:00
José Valim 9e1485f29a Start v1.7 2017-12-23 19:40:30 +01:00
Glauber Campinho 1d58413053 Introduce @deprecated (#7113) 2017-12-19 11:44:35 +01:00