Originally created by: Avazbek22
Swift compression is deliberately not shipped. This issue records the research that was done, why we decided to wait, and the exact adoption path for whenever we (or a future contributor) decide to add it. Everything below was verified hands-on, not assumed.
tree-sitter/tree-sitter-swift repository (pre-async/await era). Verified facts:Parser refuses to load it: InvalidOperationException: The language version is incompatible with this library. The shipped tree-sitter-swift.dll is dead weight.alex-pinkus/tree-sitter-swift (the de-facto standard, used across the tree-sitter ecosystem). We verified it end-to-end on win-x64: compiled with zig cc (~3.9 MiB), loaded through TreeSitter.DotNet 1.3.0 (ABI 14, runtime supports 13-15), parsed modern Swift (actors, async/await, @MainActor) with zero ERROR/MISSING nodes.1UL << FAKE_TRY_BANG in OP_SYMBOL_SUPPRESSOR shifts a 32-bit long by 32 (UB; the mask degrades to the BLOCK_COMMENT bit), affecting operator suppression around postfix ! / try! in Windows builds. Fix: alex-pinkus/tree-sitter-swift#606 (issue [#607]). Until that lands, any local build must carry this one-line patch (1UL -> 1ULL).Deep external research (including prebuilt channels: npm/PyPI prebuilds, xberg/kreuzberg language packs, nvim/Zed/Emacs ecosystems, WASM-via-wasmtime, SwiftSyntax/SourceKit) found no ready-made channel that satisfies our delivery contract (raw tree_sitter_swift shared libraries, six RIDs, verifiable provenance, no runtime downloads, no Node/Python wrappers). The cheapest reliable path is our own vendoring pipeline, already proven with Kotlin:
with-generated-files branch). Pin tag + commit + archive digest.tools/grammars/build-kotlin.ps1 into a manifest-driven builder; same zig toolchain, -O2, six RIDs (win-x64/arm64, linux-x64/arm64, osx-x64/arm64). Extend Infrastructure/Grammars/vendored/vendored-grammars.lock.json and the supply-chain tests (see VendoredGrammarSupplyChainTests) - they already enforce hash pinning.Infrastructure/Compression/Languages/Swift), modeled on Languages/Kotlin. Minimal v1 bodies:scheme
(function_declaration body: (function_body) @body)
(init_declaration body: (function_body) @body)
(deinit_declaration body: (function_body) @body)init/deinit compress - Swift state lives in stored property declarations and the signature, like C#/Kotlin (unlike Python/Ruby/PHP where constructors are preserved).var body) stay whole in v1 - they are simply not captured; this matches our property-preservation contract.async/throws/typed throws live in signatures and survive automatically.try!, try?, prefix/postfix !, custom operators - plus serialized-AST parity across all six binaries (an independent build such as the xberg language-pack bundle can serve as a comparison oracle; do NOT ship their binaries).as? ... ?? ... parse regression; a report of ~6s query compilation for a complex third-party query (our queries are short and parent-anchored, but measure query-compile time anyway, target well under 500 ms).
Originally posted by: Avazbek22
Update: the scanner fix was merged upstream - alex-pinkus/tree-sitter-swift#606 is now in
main.Consequence for the adoption path above: step 2 (carrying a local
1UL->1ULLpatch) becomes unnecessary once a source snapshot that includes both the fix and the generated files exists - either the nextwith-generated-filesrefresh (their automation updates it periodically) or the next tagged release. When picking the pin, verify the fix is present insrc/scanner.cand drop the patch/patch-hash entries from the lock schema.Also worth doing at that point: update the submodule pin in mariusgreuel/tree-sitter-dotnet-bindings#14 from
0.7.3-with-generated-filesto the post-fix snapshot, so the binding PR ships the corrected grammar.