Skip to content

BridgeJS: Diagnose async and throwing @JS struct initializers - #825

Merged
krodak merged 1 commit into
swiftwasm:mainfrom
PassiveLogic:kr/bridgejs-throwing-struct-init
Nov 3, 2026
Merged

krodak merged 1 commit into
swiftwasm:mainfrom
PassiveLogic:kr/bridgejs-throwing-struct-init

Conversation

@krodak

@krodak krodak commented Nov 3, 2026

Copy link
Copy Markdown
Member

Overview

A @JS struct with a throws(JSException) or async @JS init produced Swift glue that did not compile. The generated bridgeJSStackPop() calls the @JS init to rebuild struct values that come from JavaScript, and that call has no try or await:

@_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> Point {
    let x = Double.bridgeJSStackPop()
    return Point(x: x) // error: call can throw but is not marked with 'try'
}

A lift cannot fail, so BridgeJS now reports a diagnostic on such an initializer instead of generating code that does not build.

Testing

Added a diagnostics test for a throwing struct initializer. BridgeJS tests pass.

@krodak
krodak force-pushed the kr/bridgejs-throwing-struct-init branch from 52a4e2f to b8003b8 Compare November 3, 2026 06:20
@krodak
krodak merged commit 0d41cbf into swiftwasm:main Nov 3, 2026
16 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