handle meson_version after parsing but before invalid project() kwargs

If we add new kwargs to a function invoked on the first line, we also
need to validate the meson_version before erroring out due to unknown
kwargs. Even if the AST was successfully built.

Amusingly, we also get to improve the error message a bit. By passing
the AST node instead of an interpreter node, we get not just line
numbers, but also column offsets of the issueful meson_version. That
broke the stdout of another failing test; adapt it.
This commit is contained in:
Eli Schwartz 2023-03-01 23:09:48 -05:00
parent 878c1604e6
commit 314382d6ff
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
4 changed files with 12 additions and 1 deletions

View File

@ -117,6 +117,7 @@ class InterpreterBase:
assert isinstance(code, str)
try:
self.ast = mparser.Parser(code, mesonfile).parse()
self.handle_meson_version_from_ast()
except mparser.ParseException as me:
me.file = mesonfile
# try to detect parser errors from new syntax added by future

View File

@ -0,0 +1 @@
project('invalid project function with bad kwargs', meson_version: '0.1.0', unknown_kwarg: 'val')

View File

@ -0,0 +1,9 @@
{
"stdout": [
{
"match": "re",
"line": "test cases/failing/131 invalid project function/meson.build:1:67: ERROR: Meson version is [0-9.]+ but project requires 0.1.0"
}
]
}

View File

@ -2,7 +2,7 @@
"stdout": [
{
"match": "re",
"line": "test cases/failing/20 version/meson\\.build:1:0: ERROR: Meson version is .* but project requires >100\\.0\\.0"
"line": "test cases/failing/20 version/meson\\.build:1:44: ERROR: Meson version is .* but project requires >100\\.0\\.0"
}
]
}