Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions crates/wasmparser/src/validator/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<char>` is not valid at this time, use `stream<u8>` \
with a defined by encoding instead for now"
)
}
Ok(ComponentDefinedType::Stream(ty))
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions tests/cli/component-model/async/streams.wast
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,17 @@
)
"type mismatch for export `stream.drop-writable` of module instantiation argument ``"
)

;; stream<char> isn't valid yet
(assert_invalid
(component (type (stream char)))
"`stream<char>` is not valid at this time, use `stream<u8>` with a defined by encoding instead for now"
)
(assert_invalid
(component (type $t char) (type (stream $t)))
"`stream<char>` is not valid at this time, use `stream<u8>` with a defined by encoding instead for now"
)
(assert_invalid
(component (type (func (param "x" (stream char)))))
"`stream<char>` is not valid at this time, use `stream<u8>` with a defined by encoding instead for now"
)
21 changes: 21 additions & 0 deletions tests/snapshots/cli/component-model/async/streams.wast.json
Original file line number Diff line number Diff line change
Expand Up @@ -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<char>` is not valid at this time, use `stream<u8>` with a defined by encoding instead for now"
},
{
"type": "assert_invalid",
"line": 221,
"filename": "streams.18.wasm",
"module_type": "binary",
"text": "`stream<char>` is not valid at this time, use `stream<u8>` with a defined by encoding instead for now"
},
{
"type": "assert_invalid",
"line": 225,
"filename": "streams.19.wasm",
"module_type": "binary",
"text": "`stream<char>` is not valid at this time, use `stream<u8>` with a defined by encoding instead for now"
}
]
}