Skip to content

wast: accept import/export attributes in any order - #2780

Merged
alexcrichton merged 1 commit into
bytecodealliance:mainfrom
jrandolf:wast-attribute-order
Oct 21, 2026
Merged

alexcrichton merged 1 commit into
bytecodealliance:mainfrom
jrandolf:wast-attribute-order

Conversation

@jrandolf

Copy link
Copy Markdown
Contributor

The text format allows the attributes on import and export names (implements, version-suffix and external-id) in any order, and so does the binary format. The wast parser, however, only accepted them in one fixed order and otherwise failed with an "unexpected token" error. This accepts any order. Repeating an attribute is still an error, now with a "duplicate ... attribute" message. Printing still uses the canonical order.

@jrandolf jrandolf changed the title wast: accept import/export attributes in any order [DO NOT REVIEW] wast: accept import/export attributes in any order Oct 19, 2026
@jrandolf
jrandolf marked this pull request as ready for review October 19, 2026 22:28
@jrandolf
jrandolf requested a review from a team as a code owner October 19, 2026 22:28
@jrandolf
jrandolf requested review from fitzgen and removed request for a team October 19, 2026 22:28
@jrandolf jrandolf changed the title [DO NOT REVIEW] wast: accept import/export attributes in any order wast: accept import/export attributes in any order Oct 19, 2026
The component model text format specifies the `implements`,
`version-suffix`, and `external-id` attributes of import and export names
as an unordered `<attribute>*` list, and the binary format accepts them in
any order as well. The text parser, however, only accepted them in the
fixed order of `implements`, `version-suffix`, then `external-id`, and
anything else failed with an unhelpful "unexpected token" error pointing
at the out-of-order attribute.

This updates `ComponentExternName`'s parser, which is shared by imports,
exports, inline instance exports, and component/instance type
declarations, to accept these attributes in any order. Specifying the
same attribute more than once is still rejected, but now with an explicit
"duplicate `...` attribute" error pointing at the offending attribute.
Printing is unchanged and continues to emit attributes in a canonical
order.
@jrandolf
jrandolf force-pushed the wast-attribute-order branch from e17e03a to 2e93d18 Compare October 21, 2026 18:13
@alexcrichton
alexcrichton added this pull request to the merge queue Oct 21, 2026
Merged via the queue into bytecodealliance:main with commit 47ce26c Oct 21, 2026
37 checks passed
@jrandolf
jrandolf deleted the wast-attribute-order branch October 21, 2026 18:38
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.

2 participants