diff options
author | Charles Brunet <charles.brunet@optelgroup.com> | 2024-05-22 09:22:19 -0400 |
---|---|---|
committer | Eli Schwartz <eschwartz93@gmail.com> | 2024-06-19 00:07:01 -0400 |
commit | bef2fbf75bcea180affc19ebba280708109247a2 (patch) | |
tree | fb69d4fc74b843ddc0322dcd986c3926f6d32229 | |
parent | 9f4253164aad64297b7d8c001d953217582b2196 (diff) | |
download | meson-bef2fbf75bcea180affc19ebba280708109247a2.zip meson-bef2fbf75bcea180affc19ebba280708109247a2.tar.gz meson-bef2fbf75bcea180affc19ebba280708109247a2.tar.bz2 |
Fix crash in meson format
There was a case where a trailing comma was missing a whitespaces attribute
Fixes #13242
-rw-r--r-- | mesonbuild/mformat.py | 1 | ||||
-rw-r--r-- | test cases/format/1 default/gh13242.meson | 18 | ||||
-rw-r--r-- | test cases/format/1 default/meson.build | 1 |
3 files changed, 20 insertions, 0 deletions
diff --git a/mesonbuild/mformat.py b/mesonbuild/mformat.py index 68c9a1f..5e37019 100644 --- a/mesonbuild/mformat.py +++ b/mesonbuild/mformat.py @@ -626,6 +626,7 @@ class ArgumentFormatter(FullAstVisitor): if need_comma and not has_trailing_comma: comma = mparser.SymbolNode(mparser.Token('comma', node.filename, 0, 0, 0, (0, 0), ',')) comma.condition_level = node.condition_level + comma.whitespaces = mparser.WhitespaceNode(mparser.Token('whitespace', node.filename, 0, 0, 0, (0, 0), '')) node.commas.append(comma) elif has_trailing_comma and not need_comma: node.commas.pop(-1) diff --git a/test cases/format/1 default/gh13242.meson b/test cases/format/1 default/gh13242.meson new file mode 100644 index 0000000..b9122ec --- /dev/null +++ b/test cases/format/1 default/gh13242.meson @@ -0,0 +1,18 @@ +# Minimized meson.build +test( + args: [ + shared_library( + f'tstlib-@name@', + build_by_default: false, + override_options: opt, + ), + ], +) + +test( + should_fail: (settings.get('x', false) and not settings['y'] and dep.version( + + ).version_compare( + '>=1.2.3', + )), +) diff --git a/test cases/format/1 default/meson.build b/test cases/format/1 default/meson.build index 5b5b115..35e5b96 100644 --- a/test cases/format/1 default/meson.build +++ b/test cases/format/1 default/meson.build @@ -7,6 +7,7 @@ meson_files = { 'self': files('meson.build'), 'comments': files('crazy_comments.meson'), 'indentation': files('indentation.meson'), + 'gh13242': files('gh13242.meson'), } foreach name, f : meson_files |