propagate the most accurate node to error messages

During evaluation of codeblocks, we start off with an iteration of
nodes, and then while evaluating them we may update the global
self.current_node context. When catching and formatting errors, we
didn't take into account that the node might be updated from the
original top-level iteration.

Switch to formatting errors using self.current_node instead, to ensure
we can point at the likely most-accurate actual cause of an error.

Also update the current node in a few more places, so that function
calls always see the function call as the current node, even if the most
recently parsed node was an argument to the function call.

Fixes #11643
pull/11644/head
Eli Schwartz 2 years ago
parent 5fe7ecb861
commit 8fc4649bfe
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 9
      mesonbuild/interpreterbase/interpreterbase.py
  2. 2
      test cases/common/44 pkgconfig-gen/test.json
  3. 2
      test cases/failing/10 out of bounds/test.json
  4. 2
      test cases/failing/100 no glib-compile-resources/test.json
  5. 2
      test cases/failing/104 no fallback/test.json
  6. 2
      test cases/failing/105 feature require/test.json
  7. 2
      test cases/failing/106 feature require.bis/test.json
  8. 2
      test cases/failing/107 no build get_external_property/test.json
  9. 2
      test cases/failing/109 invalid fstring/test.json
  10. 2
      test cases/failing/11 object arithmetic/test.json
  11. 2
      test cases/failing/110 compiler argument checking/test.json
  12. 2
      test cases/failing/112 cmake executable dependency/test.json
  13. 2
      test cases/failing/118 subproject version conflict/test.json
  14. 2
      test cases/failing/119 structured source empty string/test.json
  15. 2
      test cases/failing/12 string arithmetic/test.json
  16. 2
      test cases/failing/122 cmake subproject error/test.json
  17. 2
      test cases/failing/127 extract from unity/test.json
  18. 2
      test cases/failing/13 array arithmetic/test.json
  19. 2
      test cases/failing/16 extract from subproject/test.json
  20. 2
      test cases/failing/21 subver/test.json
  21. 2
      test cases/failing/28 no crossprop/test.json
  22. 2
      test cases/failing/30 invalid man extension/test.json
  23. 2
      test cases/failing/31 no man extension/test.json
  24. 2
      test cases/failing/32 exe static shared/test.json
  25. 2
      test cases/failing/34 dependency not-required then required/test.json
  26. 2
      test cases/failing/39 kwarg assign/test.json
  27. 2
      test cases/failing/49 executable comparison/test.json
  28. 2
      test cases/failing/50 inconsistent comparison/test.json
  29. 2
      test cases/failing/56 link with executable/test.json
  30. 2
      test cases/failing/6 missing incdir/test.json
  31. 2
      test cases/failing/64 dependency not-found and required/test.json
  32. 2
      test cases/failing/65 subproj different versions/test.json
  33. 2
      test cases/failing/66 wrong boost module/test.json
  34. 2
      test cases/failing/74 link with shared module on osx/test.json
  35. 2
      test cases/failing/76 subproj dependency not-found and required/test.json
  36. 2
      test cases/failing/78 framework dependency with version/test.json
  37. 2
      test cases/failing/8 recursive/test.json
  38. 2
      test cases/failing/80 gl dependency with version/test.json
  39. 2
      test cases/failing/81 threads dependency with version/test.json
  40. 2
      test cases/failing/82 gtest dependency with version/test.json
  41. 2
      test cases/failing/86 subproj not-found dep/test.json
  42. 2
      test cases/failing/88 kwarg dupe/test.json
  43. 2
      test cases/failing/89 missing pch file/test.json
  44. 2
      test cases/failing/90 pch source different folder/test.json
  45. 2
      test cases/failing/93 add dict non string key/test.json
  46. 2
      test cases/failing/94 add dict duplicate keys/test.json
  47. 2
      test cases/failing/95 no host get_external_property/test.json
  48. 2
      test cases/rust/12 bindgen/test.json

@ -183,8 +183,9 @@ class InterpreterBase:
except Exception as e:
if getattr(e, 'lineno', None) is None:
# We are doing the equivalent to setattr here and mypy does not like it
e.lineno = cur.lineno # type: ignore
e.colno = cur.colno # type: ignore
# NOTE: self.current_node is continually updated during processing
e.lineno = self.current_node.lineno # type: ignore
e.colno = self.current_node.colno # type: ignore
e.file = os.path.join(self.source_root, self.subdir, environment.build_filename) # type: ignore
raise e
i += 1 # In THE FUTURE jump over blocks and stuff.
@ -516,6 +517,7 @@ class InterpreterBase:
func_args = flatten(posargs)
if not getattr(func, 'no-second-level-holder-flattening', False):
func_args, kwargs = resolve_second_level_holders(func_args, kwargs)
self.current_node = node
res = func(node, func_args, kwargs)
return self._holderify(res) if res is not None else None
else:
@ -544,7 +546,7 @@ class InterpreterBase:
self.validate_extraction(obj.held_object)
elif not isinstance(obj, Disabler):
raise InvalidArguments(f'Invalid operation "extract_objects" on {object_display_name} of type {type(obj).__name__}')
obj.current_node = node
obj.current_node = self.current_node = node
res = obj.method_call(method_name, args, kwargs)
return self._holderify(res) if res is not None else None
@ -598,6 +600,7 @@ class InterpreterBase:
reduced_val = self.evaluate_statement(val)
if reduced_val is None:
raise InvalidArguments(f'Value of key {reduced_key} is void.')
self.current_node = key
if duplicate_key_error and reduced_key in reduced_kw:
raise InvalidArguments(duplicate_key_error.format(reduced_key))
reduced_kw[reduced_key] = reduced_val

@ -19,7 +19,7 @@
],
"stdout": [
{
"line": "test cases/common/44 pkgconfig-gen/meson.build:164: WARNING: Project targets '>=0.60.0' but uses feature introduced in '0.62.0': pkgconfig.generate implicit variable for builtin directories."
"line": "test cases/common/44 pkgconfig-gen/meson.build:160: WARNING: Project targets '>=0.60.0' but uses feature introduced in '0.62.0': pkgconfig.generate implicit variable for builtin directories."
},
{
"line": "test cases/common/44 pkgconfig-gen/meson.build:170: WARNING: Project targets '>=0.60.0' but uses feature introduced in '0.62.0': pkgconfig.generate implicit variable for builtin directories.",

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/10 out of bounds/meson.build:4:0: ERROR: Index 0 out of bounds of array of size 0."
"line": "test cases/failing/10 out of bounds/meson.build:4:6: ERROR: Index 0 out of bounds of array of size 0."
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/100 no glib-compile-resources/meson.build:8:0: ERROR: Program 'glib-compile-resources' not found or not executable"
"line": "test cases/failing/100 no glib-compile-resources/meson.build:8:12: ERROR: Program 'glib-compile-resources' not found or not executable"
}
]
}

@ -2,7 +2,7 @@
"stdout": [
{
"match": "re",
"line": ".*/meson\\.build:2:0: ERROR: (Pkg-config binary for machine MachineChoice\\.HOST not found\\. Giving up\\.|Dependency \"foob\" not found, tried .*)"
"line": ".*/meson\\.build:2:11: ERROR: (Pkg-config binary for machine MachineChoice\\.HOST not found\\. Giving up\\.|Dependency \"foob\" not found, tried .*)"
}
]
}

@ -2,7 +2,7 @@
"stdout": [
{
"match": "re",
"line": ".*/meson\\.build:2:0: ERROR: Feature reqfeature cannot be enabled: frobnicator not available"
"line": ".*/meson\\.build:2:31: ERROR: Feature reqfeature cannot be enabled: frobnicator not available"
}
]
}

@ -2,7 +2,7 @@
"stdout": [
{
"match": "re",
"line": ".*/meson\\.build:2:0: ERROR: Feature reqfeature cannot be enabled"
"line": ".*/meson\\.build:2:31: ERROR: Feature reqfeature cannot be enabled"
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/107 no build get_external_property/meson.build:3:0: ERROR: Unknown property for build machine: nonexisting"
"line": "test cases/failing/107 no build get_external_property/meson.build:3:14: ERROR: Unknown property for build machine: nonexisting"
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/109 invalid fstring/meson.build:3:0: ERROR: Identifier \"foo\" does not name a variable."
"line": "test cases/failing/109 invalid fstring/meson.build:3:4: ERROR: Identifier \"foo\" does not name a variable."
}
]
}

@ -2,7 +2,7 @@
"stdout": [
{
"match": "re",
"line": "test cases/failing/11 object arithmetic/meson\\.build:3:0: ERROR: The `\\+` operator of str does not accept objects of type MesonMain .*"
"line": "test cases/failing/11 object arithmetic/meson\\.build:3:12: ERROR: The `\\+` operator of str does not accept objects of type MesonMain .*"
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/110 compiler argument checking/meson.build:4:0: ERROR: Compiler for C does not support \"-meson-goober-arg-for-testing\""
"line": "test cases/failing/110 compiler argument checking/meson.build:4:25: ERROR: Compiler for C does not support \"-meson-goober-arg-for-testing\""
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/112 cmake executable dependency/meson.build:9:0: ERROR: main is an executable and does not support the dependency() method. Use target() instead."
"line": "test cases/failing/112 cmake executable dependency/meson.build:9:14: ERROR: main is an executable and does not support the dependency() method. Use target() instead."
}
],
"tools": {

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/118 subproject version conflict/meson.build:4:0: ERROR: Subproject B version is 100 but ['1'] required."
"line": "test cases/failing/118 subproject version conflict/meson.build:4:8: ERROR: Subproject B version is 100 but ['1'] required."
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/119 structured source empty string/meson.build:7:0: ERROR: structured_sources: keys to dictionary argument may not be an empty string."
"line": "test cases/failing/119 structured source empty string/meson.build:9:2: ERROR: structured_sources: keys to dictionary argument may not be an empty string."
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/12 string arithmetic/meson.build:3:0: ERROR: The `+` operator of str does not accept objects of type int (3)"
"line": "test cases/failing/12 string arithmetic/meson.build:3:12: ERROR: The `+` operator of str does not accept objects of type int (3)"
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/122 cmake subproject error/meson.build:8:0: ERROR: Failed to configure the CMake subproject: Fancy error message"
"line": "test cases/failing/122 cmake subproject error/meson.build:8:14: ERROR: Failed to configure the CMake subproject: Fancy error message"
}
],
"tools": {

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/127 extract from unity/meson.build:4:0: ERROR: Single object files can not be extracted in Unity builds. You can only extract all the object files for each compiler at once."
"line": "test cases/failing/127 extract from unity/meson.build:4:37: ERROR: Single object files can not be extracted in Unity builds. You can only extract all the object files for each compiler at once."
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/13 array arithmetic/meson.build:3:0: ERROR: Object <[ArrayHolder] holds [list]: ['a', 'b']> of type array does not support the `*` operator."
"line": "test cases/failing/13 array arithmetic/meson.build:3:19: ERROR: Object <[ArrayHolder] holds [list]: ['a', 'b']> of type array does not support the `*` operator."
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/16 extract from subproject/meson.build:6:0: ERROR: Tried to extract objects from a different subproject."
"line": "test cases/failing/16 extract from subproject/meson.build:7:32: ERROR: Tried to extract objects from a different subproject."
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/21 subver/meson.build:3:0: ERROR: Subproject foo version is 1.0.0 but ['>1.0.0'] required."
"line": "test cases/failing/21 subver/meson.build:3:4: ERROR: Subproject foo version is 1.0.0 but ['>1.0.0'] required."
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/28 no crossprop/meson.build:3:0: ERROR: Unknown property for host machine: nonexisting"
"line": "test cases/failing/28 no crossprop/meson.build:3:14: ERROR: Unknown property for host machine: nonexisting"
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/30 invalid man extension/meson.build:2:0: ERROR: Man file must have a file extension of a number between 1 and 9"
"line": "test cases/failing/30 invalid man extension/meson.build:2:5: ERROR: Man file must have a file extension of a number between 1 and 9"
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/31 no man extension/meson.build:2:0: ERROR: Man file must have a file extension of a number between 1 and 9"
"line": "test cases/failing/31 no man extension/meson.build:2:5: ERROR: Man file must have a file extension of a number between 1 and 9"
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/32 exe static shared/meson.build:9:0: ERROR: Can't link non-PIC static library 'stat' into shared library 'shr2'. Use the 'pic' option to static_library to build with PIC."
"line": "test cases/failing/32 exe static shared/meson.build:9:9: ERROR: Can't link non-PIC static library 'stat' into shared library 'shr2'. Use the 'pic' option to static_library to build with PIC."
}
]
}

@ -2,7 +2,7 @@
"stdout": [
{
"match": "re",
"line": ".*/meson\\.build:4:0: ERROR: (Pkg-config binary for machine MachineChoice\\.HOST not found\\. Giving up\\.|Dependency \"foo\\-bar\\-xyz\\-12\\.3\" not found, tried .*)"
"line": ".*/meson\\.build:4:10: ERROR: (Pkg-config binary for machine MachineChoice\\.HOST not found\\. Giving up\\.|Dependency \"foo\\-bar\\-xyz\\-12\\.3\" not found, tried .*)"
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/39 kwarg assign/meson.build:3:0: ERROR: Tried to assign values inside an argument list."
"line": "test cases/failing/39 kwarg assign/meson.build:3:30: ERROR: Tried to assign values inside an argument list."
}
]
}

@ -2,7 +2,7 @@
"stdout": [
{
"match": "re",
"line": "test cases/failing/49 executable comparison/meson.build:6:0: ERROR: Object <ExecutableHolder prog1@exe: prog1(.exe)?> of type Executable does not support the `<` operator."
"line": "test cases/failing/49 executable comparison/meson.build:6:14: ERROR: Object <ExecutableHolder prog1@exe: prog1(.exe)?> of type Executable does not support the `<` operator."
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/50 inconsistent comparison/meson.build:5:0: ERROR: Object <[ArrayHolder] holds [list]: []> of type array does not support the `<` operator."
"line": "test cases/failing/50 inconsistent comparison/meson.build:5:12: ERROR: Object <[ArrayHolder] holds [list]: []> of type array does not support the `<` operator."
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/56 link with executable/meson.build:4:0: ERROR: Link target 'prog' is not linkable."
"line": "test cases/failing/56 link with executable/meson.build:4:4: ERROR: Link target 'prog' is not linkable."
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/6 missing incdir/meson.build:3:0: ERROR: Include dir nosuchdir does not exist."
"line": "test cases/failing/6 missing incdir/meson.build:3:6: ERROR: Include dir nosuchdir does not exist."
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/64 dependency not-found and required/meson.build:2:0: ERROR: Dependency is required but has no candidates."
"line": "test cases/failing/64 dependency not-found and required/meson.build:2:6: ERROR: Dependency is required but has no candidates."
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/65 subproj different versions/subprojects/b/meson.build:3:0: ERROR: Dependency 'c' is required but not found."
"line": "test cases/failing/65 subproj different versions/subprojects/b/meson.build:3:8: ERROR: Dependency 'c' is required but not found."
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/66 wrong boost module/meson.build:9:0: ERROR: Dependency \"boost\" not found, tried system"
"line": "test cases/failing/66 wrong boost module/meson.build:9:10: ERROR: Dependency \"boost\" not found, tried system"
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/74 link with shared module on osx/meson.build:8:0: ERROR: target prog links against shared module mymodule. This is not permitted on OSX"
"line": "test cases/failing/74 link with shared module on osx/meson.build:8:4: ERROR: target prog links against shared module mymodule. This is not permitted on OSX"
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/76 subproj dependency not-found and required/meson.build:2:0: ERROR: Neither a subproject directory nor a missing.wrap file was found."
"line": "test cases/failing/76 subproj dependency not-found and required/meson.build:2:10: ERROR: Neither a subproject directory nor a missing.wrap file was found."
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/78 framework dependency with version/meson.build:8:0: ERROR: Dependency lookup for appleframeworks with method 'framework' failed: Unknown version, but need ['>0']."
"line": "test cases/failing/78 framework dependency with version/meson.build:8:6: ERROR: Dependency lookup for appleframeworks with method 'framework' failed: Unknown version, but need ['>0']."
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/8 recursive/subprojects/b/meson.build:3:0: ERROR: Recursive include of subprojects: a => b => a."
"line": "test cases/failing/8 recursive/subprojects/b/meson.build:3:4: ERROR: Recursive include of subprojects: a => b => a."
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/80 gl dependency with version/meson.build:9:0: ERROR: Dependency lookup for gl with method 'system' failed: Unknown version, but need ['>0']."
"line": "test cases/failing/80 gl dependency with version/meson.build:9:6: ERROR: Dependency lookup for gl with method 'system' failed: Unknown version, but need ['>0']."
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/81 threads dependency with version/meson.build:3:0: ERROR: Dependency lookup for threads with method 'system' failed: Unknown version, but need ['>0']."
"line": "test cases/failing/81 threads dependency with version/meson.build:3:6: ERROR: Dependency lookup for threads with method 'system' failed: Unknown version, but need ['>0']."
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/82 gtest dependency with version/meson.build:8:0: ERROR: Dependency 'gtest' is required but not found."
"line": "test cases/failing/82 gtest dependency with version/meson.build:8:6: ERROR: Dependency 'gtest' is required but not found."
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/86 subproj not-found dep/meson.build:2:0: ERROR: Dependency '(anonymous)' is required but not found."
"line": "test cases/failing/86 subproj not-found dep/meson.build:2:10: ERROR: Dependency '(anonymous)' is required but not found."
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/88 kwarg dupe/meson.build:5:0: ERROR: Entry \"install\" defined both as a keyword argument and in a \"kwarg\" entry."
"line": "test cases/failing/88 kwarg dupe/meson.build:6:2: ERROR: Entry \"install\" defined both as a keyword argument and in a \"kwarg\" entry."
}
]
}

@ -2,7 +2,7 @@
"stdout": [
{
"comment": "literal 'pch/prog.h' from meson.build appears in output, irrespective of os.path.sep",
"line": "test cases/failing/89 missing pch file/meson.build:2:0: ERROR: File pch/prog.h does not exist."
"line": "test cases/failing/89 missing pch file/meson.build:2:6: ERROR: File pch/prog.h does not exist."
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/90 pch source different folder/meson.build:4:0: ERROR: PCH files must be stored in the same folder."
"line": "test cases/failing/90 pch source different folder/meson.build:4:6: ERROR: PCH files must be stored in the same folder."
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/93 add dict non string key/meson.build:9:0: ERROR: Key must be a string"
"line": "test cases/failing/93 add dict non string key/meson.build:9:9: ERROR: Key must be a string"
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/94 add dict duplicate keys/meson.build:9:0: ERROR: Duplicate dictionary key: myKey"
"line": "test cases/failing/94 add dict duplicate keys/meson.build:9:27: ERROR: Duplicate dictionary key: myKey"
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/95 no host get_external_property/meson.build:3:0: ERROR: Unknown property for host machine: nonexisting"
"line": "test cases/failing/95 no host get_external_property/meson.build:3:14: ERROR: Unknown property for host machine: nonexisting"
}
]
}

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/rust/12 bindgen/meson.build:30: WARNING: Project targets '>= 0.63' but uses feature introduced in '1.0.0': \"rust.bindgen\" keyword argument \"include_directories\" of type array[str]."
"line": "test cases/rust/12 bindgen/meson.build:27: WARNING: Project targets '>= 0.63' but uses feature introduced in '1.0.0': \"rust.bindgen\" keyword argument \"include_directories\" of type array[str]."
}
]
}

Loading…
Cancel
Save