Many editors use indentation for collapsing
so folks may want to use `var =` followed by
new line to collapse. This PR makes it possible
and aligns `=` with other operators.
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.