Skip to content

wit-parser: disallow empty tuples - #2694

Merged
dicej merged 1 commit into
bytecodealliance:mainfrom
youdie006:wit-empty-tuple
Sep 29, 2026
Merged

dicej merged 1 commit into
bytecodealliance:mainfrom
youdie006:wit-empty-tuple

Conversation

@youdie006

Copy link
Copy Markdown
Contributor

Follow-up to #2680 (#2671): wit-parser still accepts an empty tuple, which the component model rejects (crates/wasmparser/src/validator/component.rs:4257, "tuple type must have at least one type"). So

world w { import f: func(x: tuple<>); }

passes wasm-tools component wit, and the first error comes from component embed/new as decoding custom section component-type: tuple type must have at least one type (at offset 0x26), without a WIT location. type t = tuple<>; and tuple<> as a result type behave the same.

This reports empty tuple at parse time with a span, like empty records, flags, variants and enums. tests/ui/types.wit had type t24 = tuple<>;; that line is removed and types.wit.json re-blessed with BLESS=1. A new parse-fail/empty-tuple.wit sits next to empty-enum.wit.

cargo test -p wit-parser, cargo test -p wit-component, cargo fmt --check and cargo clippy -p wit-parser --all-targets pass; I did not run the workspace-wide clippy or the CLI snapshot tests.

Written with AI assistance (Claude); I have reviewed the change.

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>
@youdie006
youdie006 requested a review from a team as a code owner September 29, 2026 03:35
@youdie006
youdie006 requested review from dicej and removed request for a team September 29, 2026 03:35

@dicej dicej left a comment

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.

Thanks, @youdie006!

@dicej
dicej added this pull request to the merge queue Sep 29, 2026
Merged via the queue into bytecodealliance:main with commit 5dacd65 Sep 29, 2026
37 checks passed
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