summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Klebinger <klebinger.andreas@gmx.at>2022-08-15 12:21:30 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-08-19 14:18:03 -0400
commite5567289c576a76f62bd78bd823a824c7ca83de6 (patch)
treea113771973d732844d74b8b75784bc2b2b4dfddc
parent9789e8454ad9f315169063b344a56c4216c12711 (diff)
downloadhaskell-e5567289c576a76f62bd78bd823a824c7ca83de6.tar.gz
Fix #22048 where we failed to drop rules for -fomit-interface-pragmas.
Now we also filter the local rules (again) which fixes the issue.
-rw-r--r--compiler/GHC/Iface/Tidy.hs3
-rw-r--r--testsuite/tests/driver/T22048.hs11
-rw-r--r--testsuite/tests/driver/all.T1
3 files changed, 14 insertions, 1 deletions
diff --git a/compiler/GHC/Iface/Tidy.hs b/compiler/GHC/Iface/Tidy.hs
index 92e7e3c0df..a8529cbff7 100644
--- a/compiler/GHC/Iface/Tidy.hs
+++ b/compiler/GHC/Iface/Tidy.hs
@@ -1048,7 +1048,8 @@ findExternalRules opts binds imp_id_rules unfold_env
-- In needed_fvs', we don't bother to delete binders from the fv set
local_rules = [ rule
- | id <- bndrs
+ | (opt_expose_rules opts)
+ , id <- bndrs
, is_external_id id -- Only collect rules for external Ids
, rule <- idCoreRules id
, expose_rule rule ] -- and ones that can fire in a client
diff --git a/testsuite/tests/driver/T22048.hs b/testsuite/tests/driver/T22048.hs
new file mode 100644
index 0000000000..d8a1c07c02
--- /dev/null
+++ b/testsuite/tests/driver/T22048.hs
@@ -0,0 +1,11 @@
+module T22048 where
+
+{-# NOINLINE g #-}
+g :: Bool -> Bool
+g = not
+
+-- With -fomit-interface-pragmas these rules should not make it into interface files.
+{-# RULES
+"imported_rule" [~1] forall xs. map g xs = []
+"local_rule" [~1] forall . g True = False
+#-}
diff --git a/testsuite/tests/driver/all.T b/testsuite/tests/driver/all.T
index 5603354282..6a0932e9b0 100644
--- a/testsuite/tests/driver/all.T
+++ b/testsuite/tests/driver/all.T
@@ -312,3 +312,4 @@ test('T21866', normal, multimod_compile, ['T21866','-no-link'])
test('T21349', extra_files(['T21349']), makefile_test, [])
test('T21869', [normal, when(unregisterised(), skip)], makefile_test, [])
test('T22044', normal, makefile_test, [])
+test('T22048', [only_ways(['normal']), grep_errmsg("_rule")], compile, ["-O -fomit-interface-pragmas -ddump-simpl"])