Skip to content

Tighten versionsuffix rules and add WAST tests - #738

Open
lukewagner wants to merge 3 commits into
mainfrom
tweak-suffix
Open

lukewagner wants to merge 3 commits into
mainfrom
tweak-suffix

Conversation

@lukewagner

Copy link
Copy Markdown
Member

This PR makes the change suggested in #735 of always requiring a valid semver string (when there is a version at all).

In adding some WAST tests for versionsuffix, I noticed a few other variations from the spec and wasm-tools as captured in this PR in test/validation/version-suffix.wast. In particular: the grammar currently only allows a versionsuffix when the version in the name is "canonical" (e.g., a:b/c@1.2 is not "canonical" so it shouldn't be allowed to have a versionsuffix according to the current grammar). Also, the current text parser only parses the attributes in a fixed order, whereas the grammar parses them in any order. Happy to hear arguments if yall think we should change the spec on either of these though.

One last thing on the topic of versionsuffix: we have since added the attribute external-id, which is hyphenated, so it seems like we should name the attribute version-suffix instead. Happy to make this change in this PR too.

cc @chenyan2002 for thoughts on this too

(I'll be out for until next week, sorry in advance for slow reply.)

@chenyan2002 chenyan2002 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the grammar currently only allows a versionsuffix when the version in the name is "canonical"

I think this is implemented in bytecodealliance/wasm-tools#2693

Comment thread test/validation/version-suffix.wast Outdated
Comment thread test/validation/version-suffix.wast Outdated
Comment thread test/validation/version-suffix.wast Outdated
Comment thread test/validation/version-suffix.wast Outdated
(assert_invalid
(component
(import "a:b/c@1" (versionsuffix ".2.3") (instance))
(import "a:b/c@1" (versionsuffix ".2.3") (instance)))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

During the transition period, there is this strange mixed use of canonical name and full version:

    (import "a:b/c@1" (versionsuffix ".2.3") (instance))
    (import "a:b/c@1.2.3" (instance))

I guess we don't need to say much in the spec, but in the implementation, we do need to take care of this, and report it as an error.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I didn't add anything to the spec for this since presumably this case goes away over time.

Comment thread test/validation/version-suffix.wast
Comment thread design/mvp/Binary.md Outdated
the `versionsuffix` results in a `valid semver` as defined by
[https://semver.org](https://semver.org/). A `versionsuffix` is otherwise
ignored for validation except to improve diagnostic messages.
* 🔗 Validation requires that a `versionsuffix` is only present when the

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/is only/is/ perhaps? (to clarify it's always required for canonversion)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The update refers to the "Canonical Interface Version" section which now says that the concatenation must split at the "right" point, as defined by the pseudo-algorithm in that section, so I think that will end up forcing a suffix when you have a canonversion (except when the canonversion is valid semver on its own).

@lukewagner

lukewagner commented Oct 13, 2026 •

Copy link
Copy Markdown
Member Author

Thanks for the review! This commit updates the spec/tests to now cover the special pre-release rules (which required adding a new grammar case to canonversion for <pre-release> and also has the interesting consequence of making a grammatically-valid canonversion become invalid only once you've seen the versionsuffix) and also reject empty versionsuffix. I also changed the text format grammar from an unordered <attribute>* to an ordered attributes ::= <implements>? <versionsuffix>? <externid>? for now (until someone complains and wants to generalize to an unordered list).

With those changes and consequent WAST updates, test/validation/version-suffix.wast now passes on dev wasmtime 👍. PTAL

Only last question: could we update versionsuffix in the text format to version-suffix (to match external-id) now or sometime before releasing canonical version names as a feature? It seems like a good idea for regularity.

@alexcrichton

Copy link
Copy Markdown
Collaborator

could we update versionsuffix in the text format to version-suffix

yes!

@lukewagner

Copy link
Copy Markdown
Member Author

Awesome, renamed in the last commit.

github-actions Bot pushed a commit to SavantEnvs/wasm-tools that referenced this pull request Oct 17, 2026
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.

3 participants