Skip to content

Commit

Permalink
Properly parse quoted identifiers in function calls
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Jun 5, 2024
1 parent ad1ac3b commit 09c602d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/elixir/src/elixir_interpolation.erl
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ extract_char(Rest, Buffer, Output, Line, Column, Scope, Interpol, Last) ->
Pos = io_lib:format(". If you want to use such character, use it in its escaped ~ts form instead", [Token]),
{error, {?LOC(Line, Column), {Pre, Pos}, Token}};

[Char | NewRest] ->
[Char | NewRest] when is_list(Char) ->
extract(NewRest, lists:reverse(Char, Buffer), Output, Line, Column + 1, Scope, Interpol, Last);

[Char | NewRest] when is_integer(Char) ->
extract(NewRest, [Char | Buffer], Output, Line, Column + 1, Scope, Interpol, Last);

[] ->
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 @@ -126,6 +126,10 @@ defmodule Kernel.ParserTest do
# that are Common-script and non-ASCII
# assert Code.eval_string("_ℕ𝕩 = 1") == {1, [{:"_ℕ𝕩", 1}]}
end

test "handles graphemes inside quoted identifiers" do
assert {{:., _, [{:foo, _, nil}, :"➡️"]}, _, []} = Code.string_to_quoted!(~s|foo."➡️"|)
end
end

describe "strings/sigils" do
Expand Down
3 changes: 2 additions & 1 deletion lib/iex/test/iex/interaction_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ defmodule IEx.InteractionTest do
output = capture_iex(input)

assert output =~ "** (TokenMissingError) token missing on iex:1:"
assert output =~ "error: incomplete expression\n"
assert output =~ "error:"
assert output =~ "incomplete expression\n"
assert output =~ "iex:1"
end

Expand Down

0 comments on commit 09c602d

Please sign in to comment.