diff --git a/crates/wasmparser/src/validator/component.rs b/crates/wasmparser/src/validator/component.rs index 2b4ecbfbec..6bbb6438b9 100644 --- a/crates/wasmparser/src/validator/component.rs +++ b/crates/wasmparser/src/validator/component.rs @@ -3992,10 +3992,25 @@ impl ComponentState { "`stream` requires the component model async feature" ) } - Ok(ComponentDefinedType::Stream( - ty.map(|ty| self.create_component_val_type(ty, offset)) - .transpose()?, - )) + let ty = ty + .map(|ty| self.create_component_val_type(ty, offset)) + .transpose()?; + let prim = match ty { + Some(ComponentValType::Primitive(p)) => Some(p), + Some(ComponentValType::Type(id)) => match types[id] { + ComponentDefinedType::Primitive(p) => Some(p), + _ => None, + }, + None => None, + }; + if prim == Some(crate::PrimitiveValType::Char) { + bail!( + offset, + "`stream` is not valid at this time, use `stream` \ + with a defined by encoding instead for now" + ) + } + Ok(ComponentDefinedType::Stream(ty)) } } } diff --git a/tests/cli/component-model/async/streams.wast b/tests/cli/component-model/async/streams.wast index 5ee1787134..6f144107f7 100644 --- a/tests/cli/component-model/async/streams.wast +++ b/tests/cli/component-model/async/streams.wast @@ -211,3 +211,17 @@ ) "type mismatch for export `stream.drop-writable` of module instantiation argument ``" ) + +;; stream isn't valid yet +(assert_invalid + (component (type (stream char))) + "`stream` is not valid at this time, use `stream` with a defined by encoding instead for now" +) +(assert_invalid + (component (type $t char) (type (stream $t))) + "`stream` is not valid at this time, use `stream` with a defined by encoding instead for now" +) +(assert_invalid + (component (type (func (param "x" (stream char))))) + "`stream` is not valid at this time, use `stream` with a defined by encoding instead for now" +) diff --git a/tests/snapshots/cli/component-model/async/streams.wast.json b/tests/snapshots/cli/component-model/async/streams.wast.json index ae1de8a24b..3c1f8ca7e1 100644 --- a/tests/snapshots/cli/component-model/async/streams.wast.json +++ b/tests/snapshots/cli/component-model/async/streams.wast.json @@ -111,6 +111,27 @@ "filename": "streams.16.wasm", "module_type": "binary", "text": "type mismatch for export `stream.drop-writable` of module instantiation argument ``" + }, + { + "type": "assert_invalid", + "line": 217, + "filename": "streams.17.wasm", + "module_type": "binary", + "text": "`stream` is not valid at this time, use `stream` with a defined by encoding instead for now" + }, + { + "type": "assert_invalid", + "line": 221, + "filename": "streams.18.wasm", + "module_type": "binary", + "text": "`stream` is not valid at this time, use `stream` with a defined by encoding instead for now" + }, + { + "type": "assert_invalid", + "line": 225, + "filename": "streams.19.wasm", + "module_type": "binary", + "text": "`stream` is not valid at this time, use `stream` with a defined by encoding instead for now" } ] } \ No newline at end of file