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
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.
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.
* 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.
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.
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)
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
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.