Skip to content

fix: emit bindings for imported resources without methods - #357

Merged
andreiltd merged 1 commit into
bytecodealliance:mainfrom
carsonfarmer:cf/opaque-resource-bindings
Oct 19, 2026
Merged

andreiltd merged 1 commit into
bytecodealliance:mainfrom
carsonfarmer:cf/opaque-resource-bindings

Conversation

@carsonfarmer

@carsonfarmer carsonfarmer commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Functions returning an imported resource with no methods throw ReferenceError because the compiler never generates its class.

Generate classes for declared resources, including those without constructors or methods. Add a regression that returns and borrows one, then checks that disposing it calls the host destructor once.

Fixes #221.

@andreiltd

Copy link
Copy Markdown
Member

Hey @carsonfarmer. Sorry a bit late here. Thanks for the patch, this looks good! It looks like there is an issue where ci builds are picking up incompatible version of bindgen. The fix is here: #358.

@carsonfarmer

Copy link
Copy Markdown
Contributor Author

Cool! Do you want me to wait for that to merge and rebase this work?

@andreiltd

andreiltd commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Cool! Do you want me to wait for that to merge and rebase this work?

Yes, that would be great! Thanks!

@andreiltd

Copy link
Copy Markdown
Member

Hey @carsonfarmer, the fix went in so you can rebase 🙂

@carsonfarmer
carsonfarmer force-pushed the cf/opaque-resource-bindings branch from a47770b to 1cec9c8 Compare October 16, 2026 17:43
@carsonfarmer

Copy link
Copy Markdown
Contributor Author

Rebased and pushed :)

@carsonfarmer

Copy link
Copy Markdown
Contributor Author

Hey @andreiltd, it looks like those two windows tests are also failing on main?

@andreiltd

Copy link
Copy Markdown
Member

Hey @carsonfarmer, indded. Those flaky tests should be now fixed, by #359.

Seed resource function groups from imported resource types so opaque handles receive the existing class and disposal bindings. Add an ownership, borrowing, and disposal regression.
@andreiltd
andreiltd force-pushed the cf/opaque-resource-bindings branch from 1cec9c8 to 59aa639 Compare October 19, 2026 09:33
@andreiltd
andreiltd merged commit cbc27b9 into bytecodealliance:main Oct 19, 2026
26 checks passed
@carsonfarmer
carsonfarmer deleted the cf/opaque-resource-bindings branch October 19, 2026 15:52
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.

ReferenceError when resource has no functions

2 participants