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
2 changes: 1 addition & 1 deletion lib/elixir/src/elixir_interpolation.erl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ extract([$\\, Last, Last, Last | Rest], Buffer, Output, Line, Column, Scope, Int
extract(Rest, [Last, Last, Last | Buffer], Output, Line, Column+4, Scope, Interpol, All);

extract([$\\, $#, ${ | Rest], Buffer, Output, Line, Column, Scope, true, Last) ->
extract(Rest, [${, $#, $\\ | Buffer], Output, Line, Column+1, Scope, true, Last);
extract(Rest, [${, $#, $\\ | Buffer], Output, Line, Column+3, Scope, true, Last);

extract([$#, ${ | Rest], Buffer, Output, Line, Column, Scope, true, Last) ->
Output1 = build_string(Buffer, Output),
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/test/erlang/string_test.erl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extract_interpolations_without_interpolation_test() ->

extract_interpolations_with_escaped_interpolation_test() ->
["f\\#{o}o"] = extract_interpolations("f\\#{o}o"),
{1, 8, ["f\\#{o}o"], [], _} =
Copy link
Contributor Author

@zachallaun zachallaun Mar 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this test was asserting the incorrect thing. If I'm reading it correctly, the setup here is that we're tokenizing the following string and we expect the second number to be the column after interpolations are extracted:

"f\#{o}o"
 ^       ^
 2       10

{1, 10, ["f\\#{o}o"], [], _} =
elixir_interpolation:extract(1, 2, #elixir_tokenizer{}, true, "f\\#{o}o\"", $").

extract_interpolations_with_interpolation_test() ->
Expand Down
5 changes: 5 additions & 0 deletions lib/elixir/test/erlang/tokenizer_test.erl
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ interpolation_test() ->
{concat_op, {1, 10, nil}, '<>'},
{bin_string, {1, 13, nil}, [<<>>]}] = tokenize("\"f#{oo}\" <> \"\"").

escaped_interpolation_test() ->
[{bin_string, {1, 1, nil}, [<<"f#{oo}">>]},
{concat_op, {1, 11, nil}, '<>'},
{bin_string, {1, 14, nil}, [<<>>]}] = tokenize("\"f\\#{oo}\" <> \"\"").

capture_test() ->
% Parens precedence
[{capture_op, {1, 1, nil}, '&'},
Expand Down