From 029c37b517917e8e9bd8359754303c2632a44210 Mon Sep 17 00:00:00 2001 From: Luke Wagner Date: Mon, 21 Sep 2026 19:12:46 -0500 Subject: [PATCH] Fix value definition text format ambiguities Resolves #718 --- design/mvp/Explainer.md | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/design/mvp/Explainer.md b/design/mvp/Explainer.md index 9c36246a..0cd10c25 100644 --- a/design/mvp/Explainer.md +++ b/design/mvp/Explainer.md @@ -2431,9 +2431,9 @@ Components may define values in the value index space using following syntax: value ::= (value ? ) val ::= false | true | + | | - | nan - | '' + | "" | | (record +) | (variant ?) @@ -2446,12 +2446,22 @@ val ::= false | true | (map *) 🗺️ | (binary ) entryval ::= (entry ) 🗺️ -f64canon ::= without the `nan:0x` case. +fNcanon ::= excluding the `-nan` and `nan:0x` cases ``` -where [`core:i64`], [`core:f64`], [`core:stringchar`] and [`core:datastring`] -are as defined by the Core WebAssembly text format. +where [`core:fN`], [`core:stringchar`] and [`core:datastring`] are as defined by +the Core WebAssembly text format. -The validation rules for `value` require the `val` to match the `valtype`. +The validation rules for `value` first reject any `valtype` that transitively +contains a type constructor that doesn't have a corresponding `val` constructor. +Currently this rejects `own`, `borrow`, `future`, `stream` and `error-context`. +In particular, `(option (stream u8))` is rejected, even if the `none` case has a +`val` constructor. In the future, `val` may be extended to support more cases. + +Next, validation requires the given `val` to match the `valtype`. In particular: +* `fN` only matches `fNcanon` +* `sN` and `uN` only match `core:i64` integers that fall within their natural + signed range without wrapping (e.g., `(value s8 128)` and `(value u8 -1)` + would be rejected) The `(binary ...)` expression form provides an alternative syntax allowing the binary contents of the value definition to be written directly in the text format, analogous to data segments, @@ -3345,7 +3355,7 @@ For some use-case-focused, worked examples, see: [`core:id`]: https://webassembly.github.io/spec/core/text/values.html#text-id [`core:externidx`]: https://webassembly.github.io/spec/core/text/modules.html#text-externidx [`core:i64`]: https://webassembly.github.io/spec/core/text/values.html#integers -[`core:f64`]: https://webassembly.github.io/spec/core/text/values.html#floating-point +[`core:fN`]: https://webassembly.github.io/spec/core/text/values.html#floating-point [`core:stringchar`]: https://webassembly.github.io/spec/core/text/values.html#text-string [`core:name`]: https://webassembly.github.io/spec/core/text/values.html#text-name [`core:module`]: https://webassembly.github.io/spec/core/text/modules.html#text-module