Skip to content

Stop resolving conflicts against discarded shifts - #873

Merged
ydah merged 1 commit into
masterfrom
fix/skip-discarded-shift-conflicts
Nov 14, 2026
Merged

ydah merged 1 commit into
masterfrom
fix/skip-discarded-shift-conflicts

Conversation

@ydah

@ydah ydah commented Nov 12, 2026

Copy link
Copy Markdown
Member

compute_shift_reduce_conflicts compares reductions in kernel/closure order and keeps comparing a shift after it has been discarded. This can register a %nonassoc error even when an earlier grammar rule should already have removed that shift.

Process reductions in rule order and stop comparing once the shift is discarded, following Bison's conflict resolution (https://github.com/akimd/bison/blob/v3.8.2/src/conflicts.c#L249-L344).

For example:

%nonassoc 'b'
%precedence HIGH
%%
start: 'a' empty 'b' 'x' | direct 'b' 'y' | 'a' 'b' 'z';
empty: %empty %prec HIGH;
direct: 'a' %prec 'b';

Both LALR and IELR parsers previously rejected abx. They now accept it, matching Bison 3.8.2: empty removes the shift on 'b', so direct must not create a nonassociative error against that shift. Reversing the two rule declarations still produces the nonassociative error.

@ydah
ydah merged commit 30a832d into master Nov 14, 2026
45 checks passed
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