Commit dc41c99
fix(parser): resolve state-41 effect-row MINUS/ARROW S/R conflict via precedence
First PR of the dedicated grammar-conflict-elimination workstream
(epic #215), family A (effect-row MINUS overload), owner-prioritised
first.
In `type_expr_arrow`, after a `type_expr_primary`, lookahead `ARROW`
(continue an arrow type) or `MINUS` (open the legacy `-{E}->` effect
row, parser.mly:410) raced against reducing the base case
`type_expr_arrow -> type_expr_primary` (state 41, tokens MINUS ARROW).
Shifting is *always* the correct choice (a bare type can never both be
followed by `->`/`-{` and want to stop there), and was already Menhir's
arbitrary resolution — so making it explicit changes no parse.
Fix: a lowest-precedence pseudo-token `LOWEST_TYPE_ARROW` (never lexed)
tags the base reduction; `ARROW` is given a precedence just above it.
`MINUS` already outranks both, so on either lookahead the parser shifts
*by declared precedence* instead of by an arbitrary tie-break, and the
conflict disappears. `ARROW` is a conflict lookahead ONLY in state 41
(verified via `menhir --explain`), so giving it precedence is
side-effect-free.
Rigorous verification (full `menhir --explain` diff, baseline = #214):
- S/R arbitrarily resolved: 75 -> 72
- S/R conflict states: 25 -> 23 (state 41 eliminated)
- R/R: 10 (untouched); no new conflict states introduced
- The 16 pre-existing "precedence/`%prec` never useful" warnings are
byte-for-byte identical before and after — NOT introduced here
(they are dead precedence declarations; filed as family F on #215).
- `dune test --force` green at 257/257 (parse-behaviour-preserving).
Refs #215
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 4dea918 commit dc41c99
1 file changed
Lines changed: 15 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
86 | 100 | | |
87 | 101 | | |
88 | 102 | | |
| |||
416 | 430 | | |
417 | 431 | | |
418 | 432 | | |
419 | | - | |
| 433 | + | |
420 | 434 | | |
421 | 435 | | |
422 | 436 | | |
| |||
0 commit comments