diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2016-03-20 18:45:06 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2016-03-20 18:45:06 +0200 |
commit | 6eaeb05f8b6336f7f78b6a33e1d79831a8e629c2 (patch) | |
tree | 12aefc3b09793dcfd618802f6b9f5c17c9e0b720 /mesonbuild/interpreter.py | |
parent | 1bd3135bcbf73106990dfd980f3b32206a669f37 (diff) | |
parent | fcbd60c29117129ab8dd78c7f2af78a2e3d007e6 (diff) | |
download | meson-6eaeb05f8b6336f7f78b6a33e1d79831a8e629c2.zip meson-6eaeb05f8b6336f7f78b6a33e1d79831a8e629c2.tar.gz meson-6eaeb05f8b6336f7f78b6a33e1d79831a8e629c2.tar.bz2 |
Merge pull request #463 from tp-m/plus-assign-for-strings-and-ints
Add += support for strings and integers
Diffstat (limited to 'mesonbuild/interpreter.py')
-rw-r--r-- | mesonbuild/interpreter.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 35cbc3e..e20641d 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -2169,8 +2169,16 @@ class Interpreter(): # Remember that all variables are immutable. We must always create a # full new variable and then assign it. old_variable = self.get_variable(varname) - if not isinstance(old_variable, list): - raise InvalidArguments('The += operator currently only works with arrays.') + if isinstance(old_variable, str): + if not isinstance(addition, str): + raise InvalidArguments('The += operator requires a string on the right hand side if the variable on the left is a string') + new_value = old_variable + addition + elif isinstance(old_variable, int): + if not isinstance(addition, int): + raise InvalidArguments('The += operator requires an int on the right hand side if the variable on the left is an int') + new_value = old_variable + addition + elif not isinstance(old_variable, list): + raise InvalidArguments('The += operator currently only works with arrays, strings or ints ') # Add other data types here. else: if isinstance(addition, list): |