haskell / haskell/happy

reduce/reduce conflict handling order: difference in documentation vs. code

Open
#350 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
322
Forks
86
PR merge metrics
No merged PRs in 30d

Description

Hello,

I've read the documentation and created samples to learn a bit about Happy so I can debug the Haskell grammar for GHC.

This document here: https://github.com/haskell/happy/blob/master/doc/tips.rst
States that when there is a reduce/reduce conflict, the reduction rule that is the uppermost in the grammar file is picked.

Attached is a sample grammar with a main method. This file shows that at least here, not the first, but the last reduction rule is fixed.

Please have a look. If I understood things right and didn't mess it up in my sample code, then either Happy has a bug in its code generation or this is intended design and the documentation reflects this wrong. :)

In `ReduceReduceConflict`, `A` should be picked, but `B` is picked.
This is made visible through the evaluation of `test "#1" 3` in `main` (it should be OK for `2` and Not OK for `3`).

Kind regards,
Hai

[bug-reduce-reduce-conflict.y.txt](https://github.com/user-attachments/files/25694606/bug-reduce-reduce-conflict.y.txt)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.