From 2ca4465bbf84d87a3cd98d9890c0f15ecd7c0132 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 45aea0f48471..c25f411f1962 100644
--- a/compiler/GHC/Parser.y
+++ b/compiler/GHC/Parser.y
@@ -1011,6 +1011,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