Skip to content

Swift recovery: upstream unsafe gap and locked-C structural divergence #576

Description

@odvcencio

Summary

This issue tracks two independent facts that share one Swift witness.

  1. The locked Swift grammar does not recognize unsafe as an expression prefix.
  2. Go and locked C produce different deep trees after the shared syntax error.

The first fact is an upstream grammar gap.
The second fact is a gotreesitter strict-parity gap.
Close each scope only with its own proof.

Witnesses

Use these checked-in files:

  • grammars/testdata/swift_corpus/stdlib_FloatingPointToString.swift
  • grammars/testdata/swift_corpus/stdlib_CollectionAlgorithms.swift

The minimal syntax trigger is:

let x = unsafe bar()

Swift accepts this syntax.
The locked tree-sitter-swift grammar reports an error.

Locked reference

Use tree-sitter-swift commit 41d6e5fe811ec94229ee71771174a8cce558dfee.

The current deep digests differ on both tracked files.

Witness Go deep SHA-256 C deep SHA-256
FloatingPointToString ec51c633a3f99515cc0cd1c0cff435a44ddc7db8e83705977d28f78bdfb0fc0e ab96dddf088487acc700d72af9342c338901504dcf1d32b9644e9f6f6638190d
CollectionAlgorithms 79cf919059aa656c0d01a9a9f01d658e98e4e13d174de4bbf6560def035cb285 132d332f511f12735d80e846f52ec1fddf5f3d0dcd7a097779640a7710497487

Shared HasError() status and full-span coverage do not prove structural parity.

Gotreesitter scope

Restore exact locked-C deep-tree identity through a generic parser mechanism.
Do not add a Swift-only tree repair.
Do not add a source hash, language-name rule, or blob exception.

Keep fresh, incremental, recovery, and special routes exact.

Upstream grammar scope

Track support for the Swift unsafe expression prefix upstream.
When the locked grammar changes, import it through the normal grammar pipeline.
Do not hide the local strict-parity gap behind an upstream syntax change.

Acceptance

Close the gotreesitter scope when both witnesses match locked C node for node.
Require matching symbols, fields, spans, extras, missing nodes, and error nodes.

Close the upstream scope when the accepted locked grammar recognizes the syntax.
Regenerate the Go grammar and preserve exact C identity.

Issue #586 separately tracks shared recovery cost, memory, and retry economy.
PR #683 recorded candidate evidence but closed without merge or correctness credit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/grammarsGrammar, scanner, and query supportarea/parserParser runtime, recovery, and GLR behaviorbugSomething isn't workingcorrectnessParser correctness and reference parity

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions