Skip to content

fix WIT type alias in js-component-bindgen (see issue #1534)#1549

Merged
vados-cosmonic merged 2 commits into
bytecodealliance:mainfrom
jasoncg:issue-1534-type-alias
May 26, 2026
Merged

fix WIT type alias in js-component-bindgen (see issue #1534)#1549
vados-cosmonic merged 2 commits into
bytecodealliance:mainfrom
jasoncg:issue-1534-type-alias

Conversation

@jasoncg
Copy link
Copy Markdown

@jasoncg jasoncg commented May 25, 2026

This is a fix for issue #1534 where type aliases in some cases can cause a runtime panic.

panicked at .cargo/registry/src/index.crates.io-1949cf8c6b5b557f/js-component-bindgen-1.19.2/src/function_bindgen.rs:3647:14:
internal error: entered unreachable code: unsupported type [Id(Id { idx: 94 })] for canonical list lower

I also included a test case that passes with the fix applied.

The primary change to gen_dataview_set_and_check_fn_js_for_numeric_type() is that it now takes a wit_parser::resolve::Resolve so Type::Id(id) can be looked up.

I'm not sure if it's actually possible to end up in this state, but one potential risk since gen_dataview_set_and_check_fn_js_for_numeric_type() is now called recursively is if a Type::Id is poorly defined such that it references itself it could cause an infinite loop.

@jasoncg jasoncg marked this pull request as ready for review May 25, 2026 19:11
vados-cosmonic
vados-cosmonic previously approved these changes May 26, 2026
Copy link
Copy Markdown
Collaborator

@vados-cosmonic vados-cosmonic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

Thanks @jasoncg for this fix -- for handling Type::Id(..)s I think we can recur there rather than panicking so early -- so I'll probably add that change on before merging, but even as-is I think the code is certainly an improvement.

This commit adds support for WIT type aliases via the call to
`gen_dataview_set_and_check_fn_js_for_numeric_type()`

see: issue bytecodealliance#1534
vados-cosmonic
vados-cosmonic previously approved these changes May 26, 2026
@vados-cosmonic vados-cosmonic enabled auto-merge May 26, 2026 03:53
@vados-cosmonic
Copy link
Copy Markdown
Collaborator

vados-cosmonic commented May 26, 2026

Resolves #1534

@vados-cosmonic vados-cosmonic force-pushed the issue-1534-type-alias branch from 26df952 to f9d6442 Compare May 26, 2026 03:54
@vados-cosmonic vados-cosmonic added this pull request to the merge queue May 26, 2026
Merged via the queue into bytecodealliance:main with commit 61b3c96 May 26, 2026
45 checks passed
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.

2 participants