Skip to content

Commit 3ee2eca

Browse files
Remove duplicated metadata in nested call AST (#14122)
1 parent 71b8529 commit 3ee2eca

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/elixir/src/elixir_parser.yrl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,9 @@ extract_identifier({Kind, _, Identifier}) when
905905

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

911913
build_parens(Expr, {ArgsMeta, Args}, {BlockMeta, Block}) ->

lib/elixir/test/elixir/kernel/parser_test.exs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,10 @@ defmodule Kernel.ParserTest do
646646
assert string_to_quoted.("foo(\n) do\nend") ==
647647
{:foo, [do: [line: 2], end: [line: 3], newlines: 1, closing: [line: 2], line: 1],
648648
[[do: {:__block__, [], []}]]}
649+
650+
assert string_to_quoted.("foo(\n)(\n)") ==
651+
{{:foo, [newlines: 1, closing: [line: 2], line: 1], []},
652+
[newlines: 1, closing: [line: 3], line: 1], []}
649653
end
650654

651655
test "adds opening and closing information for single-expression block" do

0 commit comments

Comments
 (0)