diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2020-09-08 12:05:39 +0200 |
---|---|---|
committer | Daniel Mensinger <daniel@mensinger-ka.de> | 2020-09-08 19:56:20 +0200 |
commit | 4ed5c3acbf4ff4111bc9db1370d0818ad4648f5c (patch) | |
tree | 5e4c81037917aaabbf30e91148ea2a61076ac4d0 | |
parent | eca4c6fcaf7393a4a042ca2c6d104e83e0de2ffe (diff) | |
download | meson-4ed5c3acbf4ff4111bc9db1370d0818ad4648f5c.zip meson-4ed5c3acbf4ff4111bc9db1370d0818ad4648f5c.tar.gz meson-4ed5c3acbf4ff4111bc9db1370d0818ad4648f5c.tar.bz2 |
IntrospectInterpreter: allow dictionaries with nonconstant keys
Something like {a: foo} currently stymies the IntrospectionInterpreter and
breaks introspection of the source directory. The fix is just to walk the keys
and return a dummy dictionary.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | mesonbuild/ast/interpreter.py | 10 | ||||
-rw-r--r-- | test cases/unit/57 introspection/meson.build | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/mesonbuild/ast/interpreter.py b/mesonbuild/ast/interpreter.py index 6a826ef..fb77db0 100644 --- a/mesonbuild/ast/interpreter.py +++ b/mesonbuild/ast/interpreter.py @@ -192,6 +192,16 @@ class AstInterpreter(interpreterbase.InterpreterBase): self.evaluate_statement(node.trueblock) self.evaluate_statement(node.falseblock) + def evaluate_dictstatement(self, node: mparser.DictNode) -> TYPE_nkwargs: + (arguments, kwargs) = self.reduce_arguments(node.args, resolve_key_nodes=False) + assert (not arguments) + self.argument_depth += 1 + for key, value in kwargs.items(): + if isinstance(key, BaseNode): + self.evaluate_statement(key) + self.argument_depth -= 1 + return {} + def evaluate_plusassign(self, node: PlusAssignmentNode) -> None: assert(isinstance(node, PlusAssignmentNode)) # Cheat by doing a reassignment diff --git a/test cases/unit/57 introspection/meson.build b/test cases/unit/57 introspection/meson.build index 3a3db10..2b38151 100644 --- a/test cases/unit/57 introspection/meson.build +++ b/test cases/unit/57 introspection/meson.build @@ -12,6 +12,7 @@ test_bool = not test_bool set_variable('list_test_plusassign', []) list_test_plusassign += ['bugs everywhere'] +dict_test = {list_test_plusassign[0]: 'even more bugs'} if not true vers_str = '<=99.9.9' |