aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/interpreterbase.py2
-rw-r--r--mesonbuild/mparser.py7
2 files changed, 5 insertions, 4 deletions
diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py
index a04ff38..46f578e 100644
--- a/mesonbuild/interpreterbase.py
+++ b/mesonbuild/interpreterbase.py
@@ -735,7 +735,7 @@ The result of this is undefined and will become a hard error in a future Meson r
for (key, value) in addition.items():
if isinstance(key, str):
new_addition[key] = value
- elif isinstance(key, mparser.IdNode):
+ elif isinstance(key, mparser.IdNode) and isinstance(self.get_variable(key.value), str):
FeatureNew('Adding dictionary entry using string variable as key', '0.53.0').use(self.subproject)
new_addition[self.get_variable(key.value)] = value
else:
diff --git a/mesonbuild/mparser.py b/mesonbuild/mparser.py
index 2c547d8..1baf051 100644
--- a/mesonbuild/mparser.py
+++ b/mesonbuild/mparser.py
@@ -676,16 +676,17 @@ class Parser:
while not isinstance(s, EmptyNode):
potential = self.current
if self.accept('colon'):
+ key_value = self.statement()
if isinstance(s, StringNode):
if s.value in a.kwargs:
# + 1 to colno to point to the actual string, not the opening quote
raise ParseException('Duplicate dictionary key: {}'.format(s.value), self.getline(), s.lineno, s.colno + 1)
- a.set_kwarg(s.value, self.statement())
- elif isinstance(s, IdNode) and isinstance(s.value, str):
+ a.set_kwarg(s.value, key_value)
+ elif isinstance(s, IdNode) and isinstance(key_value, StringNode):
for key in a.kwargs:
if s.value == key.value:
raise ParseException('Duplicate dictionary variable key: {}'.format(s.value), self.getline(), s.lineno, s.colno)
- a.set_kwarg(s, self.statement())
+ a.set_kwarg(s, key_value)
else:
raise ParseException('Key must be a string or string variable', self.getline(), s.lineno, s.colno)
potential = self.current