BridgeJS: Unify thunk argument preparation - #22
Draft
krodak wants to merge 2 commits into
Draft
Conversation
krodak
force-pushed
the
fix/struct-self-stack-order
branch
5 times, most recently
from
September 9, 2026 12:03
67cf95d to
09dd7f3
Compare
krodak
force-pushed
the
fix/struct-self-stack-order
branch
from
September 10, 2026 11:31
09dd7f3 to
a894d36
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This fixes incorrect results from struct methods and Swift closures by preparing their arguments before the call, in the order required by the shared stacks.
1. Struct methods
These methods compile, but their generated wrappers could read
selfbefore the argument or return a number instead of a Promise:2. Closure arguments
Two array arguments could be passed to a Swift closure in the wrong order:
Changes
Lift arguments into local variables in reverse order, including
self, before calling Swift code. For async calls, this also happens before starting the task:Struct methods and closures now reuse the existing call builders. This removes the parameter-count special case and gives struct methods the normal Promise and error handling.
Generated
sendingcallbacks use a namedJSTypedClosure.sending(...)factory instead of another initializer. This fixes ambiguous initializer errors when anInt-returning async callback appears alongside an ordinary(Int) -> Voidcallback.References
sendingcallbacks involved in the initializer ambiguity.Test Plan
sendingcallbacks in the same module.[Int],[Double],[String],[JSValue], and[JSObject]../Utilities/bridge-js-generate.shnpm run check:bridgejs-dtsmake unittest SWIFT_SDK_ID=swift-6.3-RELEASE_wasm BUILD_SYSTEM=native