From a844e9bdb0ad89114e73c8ea9906606990fcfc51 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Fri, 27 Aug 2021 11:39:21 -0400 Subject: [PATCH] optinterpreter: Add support for dictionaries --- mesonbuild/optinterpreter.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mesonbuild/optinterpreter.py b/mesonbuild/optinterpreter.py index 72bf86517..27bda2ec2 100644 --- a/mesonbuild/optinterpreter.py +++ b/mesonbuild/optinterpreter.py @@ -174,6 +174,13 @@ class OptionInterpreter: lr = [self.reduce_single(curarg) for curarg in arg.args.arguments] # mypy really struggles with recursive flattening, help it out return T.cast(T.Sequence[T.Union[str, int, bool]], lr) + elif isinstance(arg, mparser.DictNode): + d = {} + for k, v in arg.args.kwargs.items(): + if not isinstance(k, mparser.StringNode): + raise OptionException('Dictionary keys must be a string literal') + d[k.value] = self.reduce_single(v) + return d elif isinstance(arg, mparser.UMinusNode): res = self.reduce_single(arg.value) if not isinstance(res, (int, float)):