Fix crash in meson format

There was a case where a trailing comma was missing a whitespaces attribute

Fixes #13242
pull/11594/head
Charles Brunet 9 months ago committed by Eli Schwartz
parent 9f4253164a
commit bef2fbf75b
  1. 1
      mesonbuild/mformat.py
  2. 18
      test cases/format/1 default/gh13242.meson
  3. 1
      test cases/format/1 default/meson.build

@ -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)

@ -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',
)),
)

@ -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

Loading…
Cancel
Save