Skip to content

Commit 5b9f4f9

Browse files
committed
handle error result from unescape_tokens in tokenizer
1 parent dc4c1cf commit 5b9f4f9

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

lib/elixir/src/elixir_tokenizer.erl

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -948,17 +948,22 @@ handle_dot([$., H | T] = Original, Line, Column, DotInfo, BaseScope, Tokens) whe
948948
InterScope
949949
end,
950950

951-
{ok, [UnescapedPart]} = unescape_tokens([Part], Line, Column, NewScope),
951+
case unescape_tokens([Part], Line, Column, NewScope) of
952+
{ok, [UnescapedPart]} ->
953+
case unsafe_to_atom(UnescapedPart, Line, Column, NewScope) of
954+
{ok, Atom} ->
955+
Token = check_call_identifier(Line, Column, H, Atom, Rest),
956+
TokensSoFar = add_token_with_eol({'.', DotInfo}, Tokens),
957+
tokenize(Rest, NewLine, NewColumn, NewScope, [Token | TokensSoFar]);
952958

953-
case unsafe_to_atom(UnescapedPart, Line, Column, NewScope) of
954-
{ok, Atom} ->
955-
Token = check_call_identifier(Line, Column, H, Atom, Rest),
956-
TokensSoFar = add_token_with_eol({'.', DotInfo}, Tokens),
957-
tokenize(Rest, NewLine, NewColumn, NewScope, [Token | TokensSoFar]);
959+
{error, Reason} ->
960+
error(Reason, Original, NewScope, Tokens)
961+
end;
958962

959963
{error, Reason} ->
960964
error(Reason, Original, NewScope, Tokens)
961965
end;
966+
962967
{_NewLine, _NewColumn, _Parts, Rest, NewScope} ->
963968
Message = "interpolation is not allowed when calling function/macro. Found interpolation in a call starting with: ",
964969
error({?LOC(Line, Column), Message, [H]}, Rest, NewScope, Tokens);

0 commit comments

Comments
 (0)