Skip to content

ISSUE 352: Fix extra initial LR(0) seed in genLR0items#353

Closed
marco-comini wants to merge 1 commit intohaskell:masterfrom
marco-comini:fix-extra-lr0-seed
Closed

ISSUE 352: Fix extra initial LR(0) seed in genLR0items#353
marco-comini wants to merge 1 commit intohaskell:masterfrom
marco-comini:fix-extra-lr0-seed

Conversation

@marco-comini
Copy link
Copy Markdown
Contributor

Fixes #352.

This patch fixes an off-by-one bug in genLR0items.

Previously, the initial LR(0) kernels were seeded with:

[0 .. n_starts]

where n_starts = length (starts g).

This caused one extra initial seeded component to be generated. Consequently, Happy could introduce many additional states coming from the first ordinary grammar production, even when that production was unrelated to the declared entry point.

This patch changes the seed range so that only the intended start rules are used.

I also added a regression test (tests/issue352.y).

@sgraf812
Copy link
Copy Markdown
Collaborator

sgraf812 commented Apr 2, 2026

Thanks! I merged this change manually without the test because our test suite isn't currently set up such that the test reproduces the issue, but it was helpful for me to verify locally. Now moving for the annoying CI upgrade that appears to strike every 3 months... Edit: Actually the pipeline on master appears to be alright. Strange.

@sgraf812
Copy link
Copy Markdown
Collaborator

sgraf812 commented Apr 2, 2026

@andreasabel and @marco-comini if you have the time, give https://hackage.haskell.org/package/happy-lib-2.2.1/candidate and https://hackage.haskell.org/package/happy-2.2.1/candidate a short glance to see if everything looks correct. Will release tomorrow

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.

Possible off-by-one in genLR0items startRules

2 participants