Skip to content

Commit 367e2b1

Browse files
committed
Advance line when processing ? followed by <LF> and \<LF>
1 parent d21a13b commit 367e2b1

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

lib/elixir/src/elixir_tokenizer.erl

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,14 @@ tokenize([$?, $\\, H | T], Line, Column, Scope, Tokens) ->
241241
end,
242242

243243
Token = {char, {Line, Column, [$?, $\\, H]}, Char},
244-
tokenize(T, Line, Column + 3, NewScope, [Token | Tokens]);
244+
case Char of
245+
$\n ->
246+
%% If a real LF was consumed as part of the char literal (e.g., ?\n with a literal newline),
247+
%% advance to the next line without emitting an EOL token.
248+
tokenize_eol(T, Line, NewScope, [Token | Tokens]);
249+
_ ->
250+
tokenize(T, Line, Column + 3, NewScope, [Token | Tokens])
251+
end;
245252

246253
tokenize([$?, Char | T], Line, Column, Scope, Tokens) ->
247254
NewScope = case handle_char(Char) of
@@ -253,7 +260,14 @@ tokenize([$?, Char | T], Line, Column, Scope, Tokens) ->
253260
Scope
254261
end,
255262
Token = {char, {Line, Column, [$?, Char]}, Char},
256-
tokenize(T, Line, Column + 2, NewScope, [Token | Tokens]);
263+
case Char of
264+
$\n ->
265+
%% If a real LF was consumed as part of the char literal (e.g., ?<LF>),
266+
%% advance to the next line without emitting an EOL token.
267+
tokenize_eol(T, Line, NewScope, [Token | Tokens]);
268+
_ ->
269+
tokenize(T, Line, Column + 2, NewScope, [Token | Tokens])
270+
end;
257271

258272
% Heredocs
259273

0 commit comments

Comments
 (0)