From ef953bdb67b15c7c20142b2209579e146700964c Mon Sep 17 00:00:00 2001 From: Marco Comini Date: Tue, 17 Mar 2026 10:50:04 +0100 Subject: [PATCH] ISSUE 352: Fix extra initial LR(0) seed in genLR0items --- lib/tabular/src/Happy/Tabular/LALR.lhs | 2 +- tests/Makefile | 2 +- tests/issue352.y | 23 +++++++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 tests/issue352.y diff --git a/lib/tabular/src/Happy/Tabular/LALR.lhs b/lib/tabular/src/Happy/Tabular/LALR.lhs index 2c109ca0..6ff7d8ea 100644 --- a/lib/tabular/src/Happy/Tabular/LALR.lhs +++ b/lib/tabular/src/Happy/Tabular/LALR.lhs @@ -237,7 +237,7 @@ information about which sets were generated by which others. > n_starts = length (starts g) > startRules :: [Set Lr0Item] -> startRules = [ Set.singleton (Lr0 rule 0) | rule <- [0..n_starts] ] +> startRules = [ Set.singleton (Lr0 rule 0) | rule <- [0..n_starts-1] ] > tokens = non_terminals g ++ terminals g diff --git a/tests/Makefile b/tests/Makefile index 056e129b..8e7d2c8a 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -39,7 +39,7 @@ TESTS = Test.ly TestMulti.ly TestPrecedence.ly bug001.ly \ typeclass_monad001.y typeclass_monad002.ly typeclass_monad_lexer.y \ rank2.y shift01.y \ AttrGrammar001.y AttrGrammar002.y \ - Pragma.y + Pragma.y issue352.y ERROR_TESTS = error001.y issue335.y diff --git a/tests/issue352.y b/tests/issue352.y new file mode 100644 index 00000000..08cbc3b0 --- /dev/null +++ b/tests/issue352.y @@ -0,0 +1,23 @@ +{ +module Issue352 where +} +%name parseS S +%tokentype { Token } +%token + a { A } + w { W } + useless { U } + +%% + +UseLess : useless UseLess { () } + | useless { () } + +S : a w { () } + +{ +data Token = A | W | U + +happyError :: [Token] -> a +happyError _ = error "err" +}