We also extend Mix.Tasks.Compiler.Diagnostic
to include {line, column} as possible position.
We also explicitly document the behaviour of
line=0, which is equivalent to unknown line.
Elixir was already setting the line to zero in
multiple occasions prior to this patch, so this
patch makes it official and we stop returning `nil`
for said cases.
For maps and lists:
$ elixir -e "%{foo: :bar, :baz => :bat}"
** (SyntaxError) nofile:1: unexpected expression after keyword list. Keyword lists must always come last in lists and maps. Therefore, this is not allowed:
[some: :value, :another]
%{some: :value, another => value}
Instead, reorder it to be the last entry:
[:another, some: :value]
%{another => value, some: :value}
Syntax error after: ','
(elixir 1.13.0-dev) lib/code.ex:655: Code.eval_string_with_error_handling/3
For calls:
$ elixir -e "call foo: :bar, :baz"
** (SyntaxError) nofile:1: unexpected expression after keyword list. Keyword lists must always come as the last argument. Therefore, this is not allowed:
function_call(1, some: :option, 2)
Instead, wrap the keyword in brackets:
function_call(1, [some: :option], 2)
Syntax error after: ','
(elixir 1.13.0-dev) lib/code.ex:655: Code.eval_string_with_error_handling/3
Closes#10973.
We need it there so we can retrieve it like this:
defmacro sigil_E({:<<>>, meta, [expr]}, []) do
options = [
line: __CALLER__.line + 1,
indentation: meta[:indentation] || 0
]
EEx.compile_string(expr, options)
end
This makes it so we're always capturing delimiter metadata for sigils
instead of requiring the `token_metadata` option. This means that we can
now show the correct sigils in ExUnit diffs (and elsewhere) for code
examples.
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)
Today charlist interpolation is quivalent to calling `String.to_charlist`
on the equivalent string interpolation. It can be more efficient by
leveraging chardata support in the `:unicode` module and encoding as a
list of literal binaries and results of `Kernel.to_string` calls for the
interpolated segments.