summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz93@gmail.com>2025-05-01 16:00:57 -0400
committerEli Schwartz <eschwartz93@gmail.com>2025-05-05 18:42:55 -0400
commitf36d680b0093e071ca54c9d20b84f9a62f88b94b (patch)
tree63ae96af7e727640fb8dc09167799f85c475a2b8
parent2d22385aa40c63927d947e3c1eadc0a6e0278d46 (diff)
downloadmeson-f36d680b0093e071ca54c9d20b84f9a62f88b94b.tar.gz
parser: update position when reporting lexer errors for unrecognized token
By default we point to the start of the most recent token we parsed. This is used when erroring out on parser issues, to print the line that caused the error, with a pointer to where we were when we got the error. In this particular case, the pointer pointed to the start of the last token we successfully parsed (col), but was not updated if we hit a token we didn't understand at all. Instead use a pointer to the unrecognized token itself. Fixes: https://github.com/mesonbuild/meson/issues/14415
-rw-r--r--mesonbuild/mparser.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/mesonbuild/mparser.py b/mesonbuild/mparser.py
index d0b32e25a..116e88fdb 100644
--- a/mesonbuild/mparser.py
+++ b/mesonbuild/mparser.py
@@ -221,7 +221,7 @@ class Lexer:
yield Token(tid, filename, curline_start, curline, col, bytespan, value)
break
if not matched:
- raise ParseException(f'lexer: unrecognized token {self.code[loc]!r}', self.getline(line_start), lineno, col)
+ raise ParseException(f'lexer: unrecognized token {self.code[loc]!r}', self.getline(line_start), lineno, loc - line_start)
@dataclass
class BaseNode: