Skip to content

Commit e6efbf4

Browse files
zhiqipanclaude
andcommitted
Fix missing comma in @_expose attribute for SwiftSyntax602
The SwiftSyntax602 code path in `buildExposeAttributes` was using array literal syntax to construct `LabeledExprListSyntax`, which doesn't set `trailingComma` on the AST nodes. This resulted in malformed attributes: `@_expose(wasm "name")` instead of `@_expose(wasm, "name")`. The fix uses the result builder syntax with explicit `.with(\.trailingComma, .commaToken())` to ensure the comma is present in the generated code. Also adds a dedicated `bridgejs-test` CI job that tests BridgeJS with multiple Swift/SwiftSyntax version combinations to ensure both code paths (pre-602 and 602+) are exercised: - Swift 6.0.3 with SwiftSyntax 600.0.1 - Swift 6.1.2 with SwiftSyntax 601.0.1 - Swift 6.2 with SwiftSyntax 602.0.0 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 8784a38 commit e6efbf4

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

.github/workflows/test.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,37 @@ jobs:
5959
- run: swift test --package-path ./Plugins/PackageToJS
6060
- run: swift test --package-path ./Plugins/BridgeJS
6161

62+
bridgejs-test:
63+
name: BridgeJS Tests
64+
strategy:
65+
matrix:
66+
include:
67+
- swift-image: "swift:6.0.3"
68+
swift-syntax-version: "600.0.1"
69+
- swift-image: "swift:6.1.2"
70+
swift-syntax-version: "601.0.1"
71+
- swift-image: "swift:6.2"
72+
swift-syntax-version: "602.0.0"
73+
runs-on: ubuntu-latest
74+
container:
75+
image: ${{ matrix.swift-image }}
76+
steps:
77+
- uses: actions/checkout@v6
78+
- name: Pin swift-syntax to exact version
79+
working-directory: Plugins/BridgeJS
80+
run: |
81+
# Use exact version constraint to pin swift-syntax
82+
sed -i 's/from: "600.0.1"/exact: "${{ matrix.swift-syntax-version }}"/' Package.swift
83+
cat Package.swift | grep swift-syntax | head -1
84+
- name: Setup Node.js
85+
uses: actions/setup-node@v4
86+
with:
87+
node-version: '20'
88+
- name: Install TypeScript
89+
run: npm install --prefix Plugins/BridgeJS/Sources/TS2Swift/JavaScript
90+
- name: Run BridgeJS tests
91+
run: swift test --package-path ./Plugins/BridgeJS
92+
6293
native-build:
6394
# Check native build to make it easy to develop applications by Xcode
6495
name: Build for native target

Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -760,10 +760,11 @@ enum SwiftCodePattern {
760760
return AttributeListSyntax {
761761
#if canImport(SwiftSyntax602)
762762
let exposeAttrArgs = AttributeSyntax.Arguments.argumentList(
763-
[
764-
LabeledExprSyntax(label: nil, expression: DeclReferenceExprSyntax(baseName: "wasm")),
765-
LabeledExprSyntax(label: nil, expression: StringLiteralExprSyntax(content: abiName)),
766-
]
763+
LabeledExprListSyntax {
764+
LabeledExprSyntax(label: nil, expression: DeclReferenceExprSyntax(baseName: "wasm"))
765+
.with(\.trailingComma, .commaToken())
766+
LabeledExprSyntax(label: nil, expression: StringLiteralExprSyntax(content: abiName))
767+
}
767768
)
768769
let cdeclAttrArgs = AttributeSyntax.Arguments.argumentList(
769770
[

0 commit comments

Comments
 (0)