Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/elixir/src/elixir_parser.yrl
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,9 @@ extract_identifier({Kind, _, Identifier}) when

build_nested_parens(Dot, Args1, {Args2Meta, Args2}, {BlockMeta, Block}) ->
Identifier = build_parens(Dot, Args1, {[], []}),
Meta = BlockMeta ++ Args2Meta ++ ?meta(Identifier),
%% Take line and column meta from the call target node
LocationMeta = lists:filter(fun({Key, _}) -> Key == line orelse Key == column end, ?meta(Identifier)),
Meta = BlockMeta ++ Args2Meta ++ LocationMeta,
{Identifier, Meta, append_non_empty(Args2, Block)}.

build_parens(Expr, {ArgsMeta, Args}, {BlockMeta, Block}) ->
Expand Down
4 changes: 4 additions & 0 deletions lib/elixir/test/elixir/kernel/parser_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,10 @@ defmodule Kernel.ParserTest do
assert string_to_quoted.("foo(\n) do\nend") ==
{:foo, [do: [line: 2], end: [line: 3], newlines: 1, closing: [line: 2], line: 1],
[[do: {:__block__, [], []}]]}

assert string_to_quoted.("foo(\n)(\n)") ==
{{:foo, [newlines: 1, closing: [line: 2], line: 1], []},
[newlines: 1, closing: [line: 3], line: 1], []}
end

test "adds opening and closing information for single-expression block" do
Expand Down
Loading