diff options
-rw-r--r-- | mesonbuild/interpreterbase.py | 4 | ||||
-rw-r--r-- | test cases/common/163 disabler/meson.build | 22 |
2 files changed, 22 insertions, 4 deletions
diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py index 5c83900..562ba27 100644 --- a/mesonbuild/interpreterbase.py +++ b/mesonbuild/interpreterbase.py @@ -682,8 +682,6 @@ The result of this is undefined and will become a hard error in a future Meson r if len(node.varnames) != 1: raise InvalidArguments('Foreach on array does not unpack') varname = node.varnames[0].value - if is_disabler(items): - return items for item in items: self.set_variable(varname, item) try: @@ -695,8 +693,6 @@ The result of this is undefined and will become a hard error in a future Meson r elif isinstance(items, dict): if len(node.varnames) != 2: raise InvalidArguments('Foreach on dict unpacks key and value') - if is_disabler(items): - return items for key, value in items.items(): self.set_variable(node.varnames[0].value, key) self.set_variable(node.varnames[1].value, value) diff --git a/test cases/common/163 disabler/meson.build b/test cases/common/163 disabler/meson.build index 8da2a0b..1f0580c 100644 --- a/test cases/common/163 disabler/meson.build +++ b/test cases/common/163 disabler/meson.build @@ -98,3 +98,25 @@ else if_is_disabled = false endif assert(if_is_disabled, 'Disabler in "if a==b" must skip both blocks') + +loops = 0 +disablers = 0 +foreach i : [true, disabler(), true] + loops += 1 + if is_disabler(i) + disablers += 1 + endif +endforeach +assert(loops == 3, 'Disabler in foreach array') +assert(disablers == 1, 'Disabler in foreach array') + +loops = 0 +disablers = 0 +foreach k, i : {'a': true, 'b': disabler(), 'c': true} + loops += 1 + if is_disabler(i) + disablers += 1 + endif +endforeach +assert(loops == 3, 'Disabler in foreach dict') +assert(disablers == 1, 'Disabler in foreach dict') |