From adfee4460a6a01de975b25e6faf9fd9261238ebd Mon Sep 17 00:00:00 2001 From: Elliot <35050275+Apache-HB@users.noreply.github.com> Date: Tue, 18 Aug 2020 10:07:59 -0400 Subject: [PATCH] prevent disabler() object from overwriting arrays (#7484) * prevent disabler object from overwriting arrays fixes #7107 * fix failing test forgot that func() != func(void) in c --- mesonbuild/interpreterbase.py | 6 ++---- .../common/235 disabler array addition/meson.build | 9 +++++++++ test cases/common/235 disabler array addition/test.c | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 test cases/common/235 disabler array addition/meson.build create mode 100644 test cases/common/235 disabler array addition/test.c diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py index 822167c98..6c4f273c5 100644 --- a/mesonbuild/interpreterbase.py +++ b/mesonbuild/interpreterbase.py @@ -810,9 +810,7 @@ The result of this is undefined and will become a hard error in a future Meson r assert(isinstance(node, mparser.PlusAssignmentNode)) varname = node.var_name addition = self.evaluate_statement(node.value) - if is_disabler(addition): - self.set_variable(varname, addition) - return + # Remember that all variables are immutable. We must always create a # full new variable and then assign it. old_variable = self.get_variable(varname) @@ -836,7 +834,7 @@ The result of this is undefined and will become a hard error in a future Meson r new_value = {**old_variable, **addition} # Add other data types here. else: - raise InvalidArguments('The += operator currently only works with arrays, dicts, strings or ints ') + raise InvalidArguments('The += operator currently only works with arrays, dicts, strings or ints') self.set_variable(varname, new_value) def evaluate_indexing(self, node: mparser.IndexNode) -> TYPE_var: diff --git a/test cases/common/235 disabler array addition/meson.build b/test cases/common/235 disabler array addition/meson.build new file mode 100644 index 000000000..231f76acf --- /dev/null +++ b/test cases/common/235 disabler array addition/meson.build @@ -0,0 +1,9 @@ +project('disabler_inside_array', 'c') + +exes = [] + +exes += library('a', 'test.c') + +exes += library('b', 'test.c', dependencies : disabler()) + +exes += library('c', 'test.c') diff --git a/test cases/common/235 disabler array addition/test.c b/test cases/common/235 disabler array addition/test.c new file mode 100644 index 000000000..e9a7aac03 --- /dev/null +++ b/test cases/common/235 disabler array addition/test.c @@ -0,0 +1 @@ +int stub(void) { return 0; }