Skip to content

fix: preserve attribute call syntax in vfmt#26769

Merged
JalonSolov merged 2 commits into
vlang:masterfrom
vincenzopalazzo:codex/fix-26766-vfmt-attrs
Mar 30, 2026
Merged

fix: preserve attribute call syntax in vfmt#26769
JalonSolov merged 2 commits into
vlang:masterfrom
vincenzopalazzo:codex/fix-26766-vfmt-attrs

Conversation

@vincenzopalazzo

Copy link
Copy Markdown
Contributor

What was broken

v fmt flattened call-style attributes like @[xml(name: 'foo')] into the older expanded form like @[xml_name: 'foo'].

Root cause

The parser normalized @[foo(...)] into multiple flat ast.Attr entries, but it did not preserve enough metadata for vfmt to know those attrs originally came from a single call-style attribute.

What changed

  • preserved minimal call-style metadata on parsed attributes
  • taught vfmt to re-emit grouped call syntax for top-level and inline attributes
  • added formatter regression coverage for named args, positional args, unsafe(), and inline field attributes

Verification

  • ./vnew -silent test vlib/v/fmt/
  • ./vnew -silent test vlib/v/parser/
  • ./vnew -silent test vlib/v/tests/comptime/comptime_attribute_call_syntax_test.v
  • reproduced issue vfmt breaks the new attributes syntax #26766 locally with ./vnew fmt

Fixes #26766

@JalonSolov

Copy link
Copy Markdown
Collaborator

Close/re-open for CI run.

@JalonSolov JalonSolov closed this Mar 30, 2026
@JalonSolov JalonSolov reopened this Mar 30, 2026
@JalonSolov JalonSolov merged commit 114fda5 into vlang:master Mar 30, 2026
88 of 89 checks passed
@vincenzopalazzo vincenzopalazzo deleted the codex/fix-26766-vfmt-attrs branch March 30, 2026 12:20
medvednikov pushed a commit that referenced this pull request Apr 4, 2026
* fix: preserve attribute call syntax in vfmt

Fixes #26766

* fix: avoid decl-after-label in v2 parser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vfmt breaks the new attributes syntax

2 participants