diff options
Diffstat (limited to 'mesonbuild/mparser.py')
-rw-r--r-- | mesonbuild/mparser.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/mesonbuild/mparser.py b/mesonbuild/mparser.py index b4fb032..2c547d8 100644 --- a/mesonbuild/mparser.py +++ b/mesonbuild/mparser.py @@ -676,14 +676,18 @@ class Parser: while not isinstance(s, EmptyNode): potential = self.current if self.accept('colon'): - if not isinstance(s, StringNode): - raise ParseException('Key must be a string.', - self.getline(), s.lineno, s.colno) - 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()) + 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): + 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()) + else: + raise ParseException('Key must be a string or string variable', self.getline(), s.lineno, s.colno) potential = self.current if not self.accept('comma'): return a |