wit-parser: disallow empty tuples - #2694
Merged
Merged
Conversation
The component model rejects a tuple type with no fields, but wit-parser accepted tuple<>, so the error only surfaced later when the component type section was validated, without a WIT location. Report it at parse time, as empty records, flags, variants and enums already are. Signed-off-by: manon <youdie006@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #2680 (#2671):
wit-parserstill accepts an empty tuple, which the component model rejects (crates/wasmparser/src/validator/component.rs:4257, "tuple type must have at least one type"). Sopasses
wasm-tools component wit, and the first error comes fromcomponent embed/newasdecoding custom section component-type: tuple type must have at least one type (at offset 0x26), without a WIT location.type t = tuple<>;andtuple<>as a result type behave the same.This reports
empty tupleat parse time with a span, like empty records, flags, variants and enums.tests/ui/types.withadtype t24 = tuple<>;; that line is removed andtypes.wit.jsonre-blessed withBLESS=1. A newparse-fail/empty-tuple.witsits next toempty-enum.wit.cargo test -p wit-parser,cargo test -p wit-component,cargo fmt --checkandcargo clippy -p wit-parser --all-targetspass; I did not run the workspace-wide clippy or the CLI snapshot tests.Written with AI assistance (Claude); I have reviewed the change.