BridgeJS: Diagnose struct initializer parameter order mismatch#733
Merged
BridgeJS: Diagnose struct initializer parameter order mismatch#733
Conversation
566d76b to
a8c17d7
Compare
a8c17d7 to
e60402c
Compare
kateinoigakukun
approved these changes
Apr 30, 2026
e60402c to
f90fe98
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
Fixes #718. Adds a diagnostic when a
@JSstruct's explicit@JS inithas parameters in a different order than the struct's stored property declarations.The stack ABI pushes/pops struct fields in declaration order, so
bridgeJSStackPop()always reconstructs the struct using property declaration order. If the user writes an init with a different parameter order, the generated code fails to compile with a confusing Swift error. This change catches the mismatch at codegen time with a clear message.Example diagnostic:
What changed:
SwiftToSkeleton.visitPost(_: StructDeclSyntax)now validates that when an explicit@JS initexists, its parameter labels match the struct's property names in declaration order.@JS initis declared, the synthesized memberwise init is assumed (always correct).