Fix newline checks in parser (#1328)

This commit is contained in:
Spencer Phillip Young authored and GitHub committed 2025-11-24 14:40:54 +01:00
1 parent f4938dccca
commit cc02b6b685
4 files changed
+15 -1

No files matched your search

@@ -1811,11 +1811,13 @@ public class Parser {
private FullToken forceNext() {
var tk = lexer.next();
precededBySemicolon = false;
var newLines = lexer.newLinesBetween;
while (tk.isAffix()) {
precededBySemicolon = precededBySemicolon || tk == Token.SEMICOLON;
tk = lexer.next();
newLines += lexer.newLinesBetween;
}
return new FullToken(tk, lexer.span(), lexer.newLinesBetween);
return new FullToken(tk, lexer.span(), newLines);
}
// Like next, but don't ignore comments
@@ -93,6 +93,7 @@ class ParserComparisonTest {
"stringError1.pkl",
"annotationIsNotExpression2.pkl",
"amendsRequiresParens.pkl",
"errors/binopDifferentLine.pkl",
"errors/parser18.pkl",
"errors/nested1.pkl",
"errors/invalidCharacterEscape.pkl",