Skip to content

BridgeJS: Fix closures with struct return#739

Merged
krodak merged 2 commits into
swiftwasm:mainfrom
wfltaylor:fix-closure-struct-return
May 11, 2026
Merged

BridgeJS: Fix closures with struct return#739
krodak merged 2 commits into
swiftwasm:mainfrom
wfltaylor:fix-closure-struct-return

Conversation

@wfltaylor
Copy link
Copy Markdown
Contributor

Currently, the following code will result in generated code that fails to compile.

@JS public struct Animal {
    public let type: String
}

@JS func roundtripAnimal(_ animalClosure: (Animal) -> Animal) -> (Animal) -> Animal

The generated code uses bridgeJSLiftReturn with no arguments, which doesn’t exist.

This fixes this by adding an overload for bridgeJSLiftReturn which uses the stack ABI.

@wfltaylor
Copy link
Copy Markdown
Contributor Author

@krodak @kateinoigakukun I’ve pushed a semi-related fix which the new tests here surfaced in the generation of the TypeScript type definitions, where Tag was incorrectly emitted as a suffix to the type. Let me know if you want me to split this into a separate PR.

@krodak krodak self-requested a review May 11, 2026 13:53
Copy link
Copy Markdown
Member

@krodak krodak left a comment

Choose a reason for hiding this comment

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

All looks good 👌🏻

@krodak krodak merged commit 5e96639 into swiftwasm:main May 11, 2026
13 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