Skip to content

Support wasip3 WIT changes in WAC parser#210

Open
ryan-surname-p wants to merge 1 commit into
bytecodealliance:mainfrom
ryan-surname-p:wit-wasip3
Open

Support wasip3 WIT changes in WAC parser#210
ryan-surname-p wants to merge 1 commit into
bytecodealliance:mainfrom
ryan-surname-p:wit-wasip3

Conversation

@ryan-surname-p

Copy link
Copy Markdown
Contributor

Closes #180 (I thought, it appears to be closed so maybe this enhances 180?)

This PR brings the WAC source language up to date with the WIT additions needed to express wasip3 components.

Since updating wasm-tools both wac-types and wac-graph have added support for WIT keywords async, stream, future and error-context.

What's left is to bring wac-parser up to date with wac-types and wax-graph.

@fibonacci1729

Copy link
Copy Markdown
Collaborator

Sorry about closing #180 (that was my mistake)!

This is great, thanks for tackling this!

@ryan-surname-p

Copy link
Copy Markdown
Contributor Author

Sorry about closing #180 (that was my mistake)!

This is great, thanks for tackling this!

no problem at all, I was worried I was missing something haha

@fibonacci1729

fibonacci1729 commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

@ryan-surname-p should i review this in its current state or are you planning to bring wac-parser up-to-date first?

@ryan-surname-p

Copy link
Copy Markdown
Contributor Author

Hey @fibonacci1729, I was actually under the impression that by updating the Lexer, AST, and AST Resolver to support the wasip3 keywords (async,stream, future, and error-context) I had done just that.

This bridges the gap between wac-parser and the wac-types / wac-graph backend.

The backend already understood these keywords. What was missing was purely the frontend surface to write them in a .wac file. So this PR just wires the frontend up to the capabilities the backend already had.

So I'm ready for a review as-is and if I missed something important please call it out and I'll take care of it as best I can.

),
))
} else if lookahead.peek(Token::StreamKeyword) {
let span = lexer.next().unwrap().1;

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.

nit: The stream and future parse arms here are nearly identical. I'll leave it up to you but it might be nice to define a helper func.

func_results: &ast::ResultList<'a>,
kind: FuncKind,
resource: Option<ResourceId>,
is_async: bool,

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.

nit: Positional booleans are mildly error-prone at call sites. I would consider adding something like:

#[derive(Clone, Copy, PartialEq, Eq)]
enum Async { No, Yes }

impl From<bool> for Async {
    fn from(b: bool) -> Self { if b { Async::Yes } else { Async::No } }
}

But again, ill leave this up to you!

@fibonacci1729 fibonacci1729 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.

This looks great!

Just two nits and few things to consider/note:

  1. It would be nice to add a negative test asserting that error-context<u8> (error-context takes no payload) or an empty stream<> is rejected.

  2. This update is technically a breaking change given the new reserved keywords so we just need to remember to call this out in the release notes and cut the next release as v0.11.0.

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.

Support latest WIT changes for P3

2 participants