Skip to content

Commit 27bb59a

Browse files
committed
add async-streams-and-futures test to wit-component
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
1 parent ec67b25 commit 27bb59a

File tree

6 files changed

+791
-7
lines changed

6 files changed

+791
-7
lines changed

crates/wit-component/src/printing.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -534,11 +534,19 @@ impl WitPrinter {
534534
self.output.push_str(">");
535535
}
536536
TypeDefKind::Type(ty) => self.print_type_name(resolve, ty)?,
537-
TypeDefKind::Future(_) => {
538-
todo!("document has an unnamed future type")
537+
TypeDefKind::Future(ty) => {
538+
if let Some(ty) = ty {
539+
self.output.push_str("future<");
540+
self.print_type_name(resolve, ty)?;
541+
self.output.push_str(">");
542+
} else {
543+
self.output.push_str("future");
544+
}
539545
}
540-
TypeDefKind::Stream(_) => {
541-
todo!("document has an unnamed stream type")
546+
TypeDefKind::Stream(ty) => {
547+
self.output.push_str("stream<");
548+
self.print_type_name(resolve, ty)?;
549+
self.output.push_str(">");
542550
}
543551
TypeDefKind::ErrorContext => self.output.push_str("error-context"),
544552
TypeDefKind::Unknown => unreachable!(),

crates/wit-component/src/validation.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,7 +1388,7 @@ impl NameMangling for Legacy {
13881388
if let Some((suffix, imported)) = module
13891389
.strip_prefix("[import-payload]")
13901390
.map(|v| (v, true))
1391-
.or_else(|| name.strip_prefix("[export-payload]").map(|v| (v, false)))
1391+
.or_else(|| module.strip_prefix("[export-payload]").map(|v| (v, false)))
13921392
{
13931393
let (key, interface) = if suffix == self.import_root() {
13941394
(WorldKey::Name(name.to_string()), None)
@@ -1469,7 +1469,11 @@ impl NameMangling for Legacy {
14691469
ty: info(key)?.ty,
14701470
}
14711471
} else if let Some(key) = match_payload_prefix(name, "[future-cancel-read-") {
1472-
validate_func_sig(name, &FuncType::new([ValType::I32], []), ty)?;
1472+
validate_func_sig(
1473+
name,
1474+
&FuncType::new([ValType::I32], [ValType::I32]),
1475+
ty,
1476+
)?;
14731477
Import::FutureCancelRead {
14741478
async_,
14751479
ty: info(key)?.ty,
@@ -1525,7 +1529,11 @@ impl NameMangling for Legacy {
15251529
ty: info(key)?.ty,
15261530
}
15271531
} else if let Some(key) = match_payload_prefix(name, "[stream-cancel-read-") {
1528-
validate_func_sig(name, &FuncType::new([ValType::I32], []), ty)?;
1532+
validate_func_sig(
1533+
name,
1534+
&FuncType::new([ValType::I32], [ValType::I32]),
1535+
ty,
1536+
)?;
15291537
Import::StreamCancelRead {
15301538
async_,
15311539
ty: info(key)?.ty,

0 commit comments

Comments
 (0)