From 44d9bf838286232ed773c1521e71bb46118a3d0e Mon Sep 17 00:00:00 2001 From: Karim Taha <kariem.taha2.7@gmail.com> Date: Fri, 25 Oct 2024 18:13:36 +0300 Subject: [PATCH] Split `module' productions into two, one without a following catch, and one with. The motivation is that some parsing errors still halt the whole pipeline due to wrong interaction between the catch mechansim and the layout rule requiring emission of `error' tokens, So we try to keep as much info in the source up until the occurrence of error. --- compiler/GHC/Parser.y | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compiler/GHC/Parser.y b/compiler/GHC/Parser.y index 82386c34d471..05ef3b6236c4 100644 --- a/compiler/GHC/Parser.y +++ b/compiler/GHC/Parser.y @@ -1012,6 +1012,10 @@ signature :: { Located (HsModule GhcPs) } ) } module :: { Located (HsModule GhcPs) } + : module_no_catch { $1 } + | module_no_catch catch { $1 } + +module_no_catch :: { Located (HsModule GhcPs) } : 'module' modid maybe_warning_pragma maybeexports 'where' body {% fileSrcSpan >>= \ loc -> acsFinal (\cs eof -> (L loc (HsModule (XModulePs -- GitLab