CST lowering widens constraint-pattern locations through redundant parentheses
I maintainer di solito rispondono entro 1 giorno
@myfreess ci sta già lavorando.
Dal 24/9/2026.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
At a01fd77e599c12cf9a2182df3456990e74f53ced, CST-to-AST lowering disagrees with both Handrolled and MoonYacc on the location of a grouped type-constrained pattern.
fn f(x) { let ((x : Int)) = x; x }
With @basic.show_loc.protect(String, ...), the Pattern::Constraint node covers:
| Entry point | Location | Source slice |
|---|---|---|
| Handrolled | 1:16-1:25 |
(x : Int) |
| MoonYacc | 1:16-1:25 |
(x : Int) |
| CST lowering | 1:15-1:26 |
((x : Int)) |
There are no syntax diagnostics, and the location-hidden ASTs agree. Further grouping keeps widening only the CST-derived span. The direct (x : Int) case already agrees across all three implementations.
lower_tuple_pattern replaces the location of any lowered Constraint with the current group's location. This also runs when the raw child is another grouping node, rather than the annotation itself. A candidate fix limits this replacement to a direct Pattern_Constraint child and preserves the lowered span for outer groups. The existing grouped-pattern location test compares Handrolled and MoonYacc, but does not include CST lowering.
The regression file compiles with --deny-warn before applying any patch. Unmodified upstream produces seven assertion failures and three passing controls; applying only this fix makes the same ten tests pass. Cases cover repeated grouping, annotated tuples, constructors, arrays, nested annotations, multiline input and unannotated controls. Tests check source slices and complete location-aware AST parity; no snapshots were changed.
I also combined this patch with the separate candidate from #188 and ran the full suite: wasm 2763/2763, wasm-gc 2760/2760, JS 2760/2760, native 2765/2765. These totals include 17 new cases and the existing upstream tests. The result JSON and logs were downloaded and inspected.
Environment: moonc v0.10.14+7d59c7ec9, moon 0.1.20260920. mooninfo accepts all ten inputs without parse-error or deprecated-syntax flags; its exported locations are null, so it is used for syntax eligibility, not as a location oracle.
Is preserving the inner constraint span the intended contract? The patch and regression are ready for a focused PR after confirmation.
- Lingua principale
- MoonBit
- Stelle
- 35
- Fork
- 10
- Merge medio
- 8h 2m
- PR unite (30g)
- 17
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
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 moonbitlang/parser
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
moonbitlang/parser#202 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 82/100
moonbitlang/parser#201 ·
I maintainer di solito rispondono entro 1 giorno
-
Negative constant pattern locations exclude the minus sign in Handrolled and CST loweringForse di nuovo libera @Yoorkin l’ha presa 36 giorni fa e non c’è nessuna pull request aperta. Apertabug good first issue
moonbitlang/parser#188 · 2 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno