From 367e2b17d50c0607b564191ea7e2cbf7534a1fc5 Mon Sep 17 00:00:00 2001 From: Lukasz Samson Date: Mon, 18 Aug 2025 22:29:23 +0200 Subject: [PATCH] Advance line when processing ? followed by and \ --- lib/elixir/src/elixir_tokenizer.erl | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/elixir/src/elixir_tokenizer.erl b/lib/elixir/src/elixir_tokenizer.erl index 3c38062ec1..c526980573 100644 --- a/lib/elixir/src/elixir_tokenizer.erl +++ b/lib/elixir/src/elixir_tokenizer.erl @@ -241,7 +241,14 @@ tokenize([$?, $\\, H | T], Line, Column, Scope, Tokens) -> end, Token = {char, {Line, Column, [$?, $\\, H]}, Char}, - tokenize(T, Line, Column + 3, NewScope, [Token | Tokens]); + case Char of + $\n -> + %% If a real LF was consumed as part of the char literal (e.g., ?\n with a literal newline), + %% advance to the next line without emitting an EOL token. + tokenize_eol(T, Line, NewScope, [Token | Tokens]); + _ -> + tokenize(T, Line, Column + 3, NewScope, [Token | Tokens]) + end; tokenize([$?, Char | T], Line, Column, Scope, Tokens) -> NewScope = case handle_char(Char) of @@ -253,7 +260,14 @@ tokenize([$?, Char | T], Line, Column, Scope, Tokens) -> Scope end, Token = {char, {Line, Column, [$?, Char]}, Char}, - tokenize(T, Line, Column + 2, NewScope, [Token | Tokens]); + case Char of + $\n -> + %% If a real LF was consumed as part of the char literal (e.g., ?), + %% advance to the next line without emitting an EOL token. + tokenize_eol(T, Line, NewScope, [Token | Tokens]); + _ -> + tokenize(T, Line, Column + 2, NewScope, [Token | Tokens]) + end; % Heredocs