Skip to content

fix(swift): index every case of a comma-separated enum case list - #3200

Open
bob-codedaptive wants to merge 1 commit into
colbymchenry:mainfrom
codedaptive:pr/swift-enum-cases
Open

bob-codedaptive wants to merge 1 commit into
colbymchenry:mainfrom
codedaptive:pr/swift-enum-cases

Conversation

@bob-codedaptive

Copy link
Copy Markdown

What was wrong

case object([Int]), array([Value]), boolean(Bool), null is one enum_entry in the Swift grammar with four name fields. Both extractors read a single name field, so only object was indexed. array, boolean and null were missing from search, callers and impact, and anything that looked a case up by name saw an enum without them.

What this changes

Every name field of an enum_entry becomes an enum_member, in both extractors (extractEnumMembers for the wasm path and extract_enum_members in the native kernel), with identical results. A single-case entry is unchanged and still spans the whole entry; each case of a multi-case entry spans its own name. Node ids come from the name and line, and the column only separates a collision.

docs/design/swift-kernel-port-checklist.md and the two header comments that listed first-case-only minting as a quirk to preserve now describe every case being kept.

Tests

__tests__/swift-enum-multi-case.test.ts has a wasm arm and a kernel arm that must mint the same nodes. The kernel arm runs when a kernel is staged (npm run build:kernel), like the kernel parity suite.

  • npx vitest run __tests__/swift-enum-multi-case.test.ts, wasm arm: 1 test, passes. On current main, without the tree-sitter.ts change, it fails (array, boolean and null are missing).
  • kernel arm: not run by the author. The kernel change compiles (npm run build:kernel); the kernel built on the author's machine would not load, so the arm and kernel-swift-parity.test.ts were skipped.

The existing corpus in __tests__/fixtures/kernel-parity/torture.swift holds no multi-case entry, so kernel-swift-parity.test.ts does not exercise this on its own; the new test's kernel arm does.

  • Platform: tested on macOS only; not run on Linux or Windows.

🤖 Generated with Claude Code

case object([Int]), array([Value]), null indexed only its first case: both the
TypeScript extractor and the native kernel read one name field from the enum
entry. Every name field now becomes an enum member, on both paths with identical
results; a single-case entry is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T15:42:20.144138Z bd2e11f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant