{{ message }}
[NFC] BridgeJS: Make JSGlueGen and IntrinsicJSFragment methods throwable#606
Merged
kateinoigakukun merged 2 commits intoFeb 9, 2026
Merged
[NFC] BridgeJS: Make JSGlueGen and IntrinsicJSFragment methods throwable#606kateinoigakukun merged 2 commits into
kateinoigakukun merged 2 commits into
Conversation
Instead of crashing on errors in JS code generation for BridgeJSLink, we should prefer propagating errors.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates BridgeJSLink’s JS glue code generation to propagate failures via Swift throws instead of crashing (previously via try! / forced failures), improving error handling during BridgeJSLink codegen.
Changes:
- Make
IntrinsicJSFragment.printCodeand several BridgeJSLink generation helpersthrows, updating call sites to usetry. - Update intrinsic registration APIs (
JSIntrinsicRegistry.register,JSGlueVariableScope.registerIntrinsic) to accept throwing builders (rethrows). - Replace prior
try!usage across codegen paths (arrays/dictionaries/struct helpers/closure helpers) with error propagation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift |
Converts intrinsic fragment emission to throwing, removing try! and propagating codegen errors upward. |
Plugins/BridgeJS/Sources/BridgeJSLink/CodeFragmentPrinter.swift |
Allows intrinsic builders to throw (rethrows) during registration. |
Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift |
Updates JS glue generation to call throwing fragment builders and propagate errors via throws. |
Comments suppressed due to low confidence (1)
Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift:3873
- The generated JS for optional associated-value enum struct fields includes an extra trailing comma in the
.lift(...)call (e.g....lift(caseIdVar, );), which will produce a JavaScript syntax error at runtime. Remove the stray comma so the generated call is valid; this same pattern also appears in the associated-value-enum lifting path used elsewhere in this file.
try printer.indent {
// Special handling for associated value enum - in struct fields, case ID is pushed to i32Stack
if case .associatedValueEnum(let enumName) = wrappedType {
let base = enumName.components(separatedBy: ".").last ?? enumName
let caseIdVar = scope.variable("enumCaseId")
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
Hide details
View details
kateinoigakukun
merged commit
c336a3f
into
main
Feb 9, 2026
11 checks passed
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
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.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.
Instead of crashing on errors in JS code generation for BridgeJSLink, we should prefer propagating errors.