Commit Graph
1892 Commits
Author SHA1 Message Date
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
José Valim 560e721b9b Remove unused funtionality and erase pdict properly 2019-10-25 15:29:46 +02:00
José Valim 649914c394 Validate bind_quoted, closes #9406 2019-10-21 21:08:02 +02:00
José Valim 69d085abd4 Improve errors for calls on aliases 2019-10-21 21:02:00 +02:00
Fernando Tapia Rico a01d7751ec Remove redundant guard
Kudos to @michalmuskala
2019-10-14 11:57:51 +02:00
Fernando Tapia Rico 66a289056e Raise when passing an empty list instead of clauses (#9402)
This fixes an edge case in which the compiler will process an
empty list value (`[]`) as a block with no clauses, which is not
possible.

Here is an example:

    with {:ok, value} <- Map.fetch(%{a: 1}, :a) do
      value
    else
      []
    end

With this change, the code above will not compile.
2019-10-13 16:50:05 +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 f52f2c7952 Ensure compilation works for a variable named super, closes #9390 2019-10-09 19:11:04 +02:00
Eric Meadows-Jönsson 9f334a73ca Move map.ex to bootstrap (#9389) 2019-10-08 14:39:05 +02:00
José Valim fd49a67f34 Add defmodule tracing event 2019-10-07 16:12:52 -03:00
Björn Gustavsson 9f8593fd6b Optimize elixir_tokenizer (#9347)
When comparing characters in `elixir_tokenizer`, replace `==` and `/=`
with the more efficient `=:=` and `=/=` operators.

The `=:=` and `=/=` operators are more efficient because they can
only return `true` if the operands have the same type:

    1> $* =:= 42.
    true
    2> $* =:= 42.0.
    false

In contrast, the `==` operator can return `true` when comparing
an integer and a float:

    3> $* == 42.0.
    true

Using `=:=` and `=/=` also gives the Erlang compiler more opportunites
for optimization. For example, when compiling the `is_sigil` macro,
the compiler can combine all eight comparisons into a single `select_val`
instruction instead of emitting eight separate instructions.
2019-09-14 12:42:07 +02:00
José Valim 94b507841b Add struct keys to tracing on struct expansion 2019-09-01 09:52:18 -06:00
José Valim 3efda3155c Raise multiple args errors in case with guards, closes #9311 2019-08-23 10:06:21 +02:00
Eric Meadows-Jönsson 0f47a58bf8 Support struct patterns (#9306) 2019-08-22 13:28:05 -07:00
Eric Meadows-Jönsson 807e205b75 Split Module.Types and add unit tests (#9303) 2019-08-20 11:46:13 -07:00
José Valim 22f70afe4c Warn when function head comes immediately after the implementation 2019-08-15 19:23:38 +02:00
José Valim 4477115675 Use an empty keyword list instead of nil for empty definitions 2019-08-14 14:51:49 +02: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
Eric Meadows-Jönsson c5d5e7f462 Add inference of function head to find function clauses that will never match (#9270) 2019-08-08 14:02:27 +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 9540e9fd6a Raise correct error message for incomplete interpolation in heredoc, closes #9252 2019-07-30 18:36:41 +02:00
José Valim ce5602bee1 Include file+line range in eval errors 2019-07-29 15:20:13 +02:00
José Valim b3201224b3 Reduce private API surface 2019-07-29 15:20:13 +02:00
José Valim 783ceb4507 Ensure local captures work correctly on macro expansion
Closes #9245
2019-07-27 11:28:05 +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
Eric Meadows-Jönsson 1956e95808 Remove dispatch tracking in LexicalTracker (#9228) 2019-07-18 13:48:02 +02:00
Allen Madsen dc24889fee Change :attributes to :warn_attributes for clarity (module bag table) (#9223) 2019-07-14 15:35:29 +02:00
Eric Meadows-Jönsson f418ed247c Add ExCk chunk (#9203) 2019-07-09 21:23:38 +02:00
Allen Madsen f2c63bf030 Add Module.has_attribute?/2 (#9200) 2019-07-09 17:21:04 +02:00
Eric Meadows-Jönsson f88676db9b Move deprecation check to group pass (#9176) 2019-07-03 09:56:35 +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 82b8c81004 Make sure locals tracker can be stopped 2019-06-27 10:12:15 +02:00
José Valim 6c30171053 Do not pass Meta to Erlang AST, closes #9152 2019-06-21 16:57:36 +02:00
José Valim f38895cebb Add literal encoder option to Code.string_to_quoted 2019-06-19 00:04:08 +02:00
José Valim 776225f4e1 Add end of expression token information
This also renames pairing_metadata to token_metadata,
as it mostly contains information about related tokens
and not necessarily pairs.
2019-06-18 00:25:22 +02:00
José Valim faefb0b882 Exposing pairing metadata (#9146)
This introduces five new metadata nodes:

  * `do` - contains metadata about do location in a function call with
    `do/end` blocks
  * `end` - contains metadata about end location in a function call with
    `do/end` blocks
  * `closing` - contains metadata about the closing pair, such as a `}`
    in a tuple or in a map, or such as the closing `)` in a function call
    with parens
  * `eol` - is set to true when the opening pair, such as `{` or `(`, are
    followed by the end of the line
  * `delimiter` - contains the opening for sigils (such as `"{"`, `"/"`,
    etc)
2019-06-17 16:38:52 +02:00
José Valim e2c78e8ba9 Rename :end metadata to less ambiguous :closing 2019-06-16 00:01:48 +02:00
José Valim b23b75d709 Add TODO 2019-06-13 20:03:27 +02:00
José Valim 74d33cba0c Remove unused import_fa metadata 2019-06-13 19:57:31 +02:00
José Valim a369190f42 Improve undefined struct messages 2019-06-10 11:19:00 +02:00
José Valim e1b68261b3 Raise on recursive macros (#9111)
Closes #9101.
2019-06-03 17:34:15 +02:00
José Valim ce41a70b2e Update registered process lists, closes #9103 2019-05-31 19:24:17 +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
Ryan Bigg 679f978e35 Add 'a' to {invalid_clauses, Name} error (#9090) 2019-05-29 07:42:00 +02:00
Daniil Fedotov 145b7019ae Make regexes fall back to binary matching on incompatible runtime version (#9040)
Regexes are precompiled to binary values during code compilation.
These binary values may be incompatible between different PCRE versions
and OS endianness. This makes code less portable to achieve slight
performance improvement.

PCRE version and endianness are parts of Regex structure and may be
checked in runtime.

This commit adds this check and makes regex execution fall back 
to binary matching if versions are incompatible.

This slightly reduces performance (around 5% for simple regexes) for
compatible versions because there is an additional version read.
Also for incompatible versions it's as fast as binary matching.
2019-05-21 09:34:55 +02:00
kw7oe f44adfbeb0 Improve heredoc error message (#9048) 2019-05-19 10:10:11 +02:00
José Valim 10fd316439 Delegate Erlang/OTP version check to Elixir 2019-05-15 17:23:26 +02:00
Victor Rodrigues 7e6bac3450 Do not allow defmodule with special atoms (#9032)
Fixes #9030
2019-05-10 20:47:36 +02:00