[Bug]: Swift: a local with same name as a modifier (prefix, open, final...) used in a switch case body gives a syntax-parse error from tree-sitter-swift
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 65/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Ambito
- developer-experience, tooling
Direzione di ricerca
L’issue indica extract.py, la parametrizzazione dei test Swift e il changelog. Leggi la gestione esistente degli identificatori che prendono il nome dai modificatori ed esegui i due file di test Swift menzionati nell’issue. Il lavoro è completato quando le espressioni switch-case interessate vengono analizzate, i sei nomi aggiuntivi sono inclusi e questi test passano; le eccezioni elencate restano invariate.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Pre-flight checks
- I have checked the Troubleshooting section in the README
What happened?
Summary:
tree-sitter-swift 0.7.4 cannot parse a local value whose name is a Swift contextual modifier when it is used as return name <operator> or return name.member inside a switch case. The grammar reads the identifier as a declaration modifier waiting for a declaration, and the surrounding code collapses into ERROR nodes. Graphify warns about a syntax-parse error at line: X and extracts the file only partially.
Related but distinct: #3540 (another tree-sitter-swift parse failure, if let x = await ...).
The trigger is a modifier-named identifier at the start of an expression statement inside a case body, followed by an operator or member access.
Limits and unfixed exceptions (the fix doesn't cover these, so behavior is unchanged: partial extraction plus the warning):
- A function parameter named like a modifier. Renaming it would change the argument label and every call site.
- A closure parameter, as in
xs.map { prefix in ... }. - Tuple destructuring, as in
let (prefix, b) = t. - A file with any other syntax error, because the rewrite is accepted only if the whole file then parses cleanly.
- Names I haven't tested. The list is only what I verified.
Covered: if let prefix = x, and a type-scope property with the same name.
Code change: added six names that also fail to extract.py, the test parametrization, and the changelog: distributed, nonmutating, public, private, internal and fileprivate.
Validation: The Swift tests pass, 36 of 36 in the two files I re-ran after the change. I did not re-run the full suite because it had 8 failures before this change, and they also fail without this fix.
static, class and inout also error, but they are reserved keywords, so let class = 1 isn't valid Swift.
Steps to reproduce
Minimal repro
let prefix = "x"
switch kind {
case 0:
return prefix + "a" // error
| Case body | Result |
|---|---|
return prefix + "a" |
error |
return prefix.count > 0 ? "a" : "b" |
error |
return prefix |
ok |
print(prefix) |
ok |
let y = prefix |
ok |
x = prefix + "a" |
ok |
return "a" + prefix |
ok |
return pfx + "a" (local renamed) |
ok |
return prefix + "a" inside if k == 0 { ... } instead of a switch |
ok |
return prefix + "a" after the switch, outside any case |
ok |
Error output or graph output
codefile.swift had a syntax-parse error at line X, so its extraction may be partial (Y symbols found).
Graphify version
0.9.102
Operating System
macOS
Python Version
3.13
Installation Method
uv tool install (recommended)
Additional Environment Details
No response
Additional context
No response
- Lingua principale
- Python
- Stelle
- 124k
- Fork
- 11.9k
- Merge medio
- 2h 35m
- PR unite (30g)
- 6
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Graphify-Labs/graphify
-
[Bug]: valid JSON with the wrong global-manifest shape bypasses recoveryForse già presa @azizur100389 l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
Graphify-Labs/graphify#5020 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: malformed learning sidecar data can hide valid annotationsForse già presa @azizur100389 l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
Graphify-Labs/graphify#5019 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: graphify update skips or partially rebuilds a missing graph when the manifest survivesForse già presa @azizur100389 l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
Graphify-Labs/graphify#5016 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
extract --out <dir>: semantic cache never saved, docs missing from manifest (relative source_file resolved against --out)Forse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
Graphify-Labs/graphify#4831 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
hooks: last-resort `python3` probe launches the Microsoft Store redirector on Windows (visible console flash, exit 9009)Forse già presa @Deepjyoti-Sarmah l’ha presa 18 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
Graphify-Labs/graphify#4563 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di Graphify-Labs/graphify
Issue simili
-
docs size:S
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
strawberry-graphql/strawberry#4794 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
dataforgoodfr/cetolog#21 ·
-
security_citations_test fails against ecc 2026.11.6: SECURITY.md quotes ecc v2026.11.2's linesAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
btclib-org/btclib#2932 ·
I maintainer di solito rispondono entro 1 giorno