summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2023-01-27 10:04:38 +0000
committerMatthew Pickering <matthewtpickering@gmail.com>2023-01-27 17:20:44 +0000
commitafc9d4c7bad05b17612b2572d96458bde68aa5dd (patch)
treef2601d9fff7d06f1221c2c12931612ffc1842801
parent545bf8cf1844e2a1c18d2019d1f299ab10099873 (diff)
downloadhaskell-wip/t22807-test.tar.gz
Improve error message in tc_iface_binding and add broken test for #22807wip/t22807-test
I improved the error message in tc_iface_binding to avoid the "no match in record selector" error. Also added the currently broken test for #22807 which could be fixed by !6080
-rw-r--r--compiler/GHC/IfaceToCore.hs9
-rw-r--r--testsuite/tests/driver/fat-iface/Makefile4
-rw-r--r--testsuite/tests/driver/fat-iface/T22807A.hs6
-rw-r--r--testsuite/tests/driver/fat-iface/T22807B.hs5
-rw-r--r--testsuite/tests/driver/fat-iface/all.T2
5 files changed, 25 insertions, 1 deletions
diff --git a/compiler/GHC/IfaceToCore.hs b/compiler/GHC/IfaceToCore.hs
index fa714448ac..1a246dac5f 100644
--- a/compiler/GHC/IfaceToCore.hs
+++ b/compiler/GHC/IfaceToCore.hs
@@ -933,7 +933,14 @@ tc_iface_bindings (IfaceRec bs) = do
-- | See Note [Interface File with Core: Sharing RHSs]
tc_iface_binding :: Id -> IfaceMaybeRhs -> IfL CoreExpr
-tc_iface_binding i IfUseUnfoldingRhs = return (unfoldingTemplate $ realIdUnfolding i)
+tc_iface_binding i IfUseUnfoldingRhs =
+ case maybeUnfoldingTemplate $ realIdUnfolding i of
+ Just e -> return e
+ Nothing -> pprPanic "tc_iface_binding" (vcat [text "Binding" <+> quotes (ppr i) <+> text "had an unfolding when the interface file was created"
+ , text "which has now gone missing. Perhaps you loaded the interface file with `-fignore-interface-pragmas`"
+ , text "but compiled it with `-fno-omit-interface-pragmas`. If this is you, leave a comment on #20021"
+ , text "Unfolding:" <+> ppr (realIdUnfolding i)])
+
tc_iface_binding _ (IfRhs rhs) = tcIfaceExpr rhs
mk_top_id :: IfaceTopBndrInfo -> IfL Id
diff --git a/testsuite/tests/driver/fat-iface/Makefile b/testsuite/tests/driver/fat-iface/Makefile
index 7241e48333..c8715fe240 100644
--- a/testsuite/tests/driver/fat-iface/Makefile
+++ b/testsuite/tests/driver/fat-iface/Makefile
@@ -49,4 +49,8 @@ fat010: clean
echo >> "THB.hs"
"$(TEST_HC)" $(TEST_HC_OPTS) THC.hs -fhide-source-paths -fwrite-if-simplified-core -fprefer-byte-code
+T22807: clean
+ "$(TEST_HC)" $(TEST_HC_OPTS) T22807A.hs -fhide-source-paths -fwrite-if-simplified-core -fbyte-code-and-object-code -fno-omit-interface-pragmas -fprefer-byte-code
+ "$(TEST_HC)" $(TEST_HC_OPTS) T22807B.hs -fhide-source-paths -fwrite-if-simplified-core -fprefer-byte-code -fbyte-code-and-object-code -fno-omit-interface-pragmas
+
diff --git a/testsuite/tests/driver/fat-iface/T22807A.hs b/testsuite/tests/driver/fat-iface/T22807A.hs
new file mode 100644
index 0000000000..8a86caf95e
--- /dev/null
+++ b/testsuite/tests/driver/fat-iface/T22807A.hs
@@ -0,0 +1,6 @@
+module T22807A where
+
+xs :: [a]
+xs = []
+
+
diff --git a/testsuite/tests/driver/fat-iface/T22807B.hs b/testsuite/tests/driver/fat-iface/T22807B.hs
new file mode 100644
index 0000000000..5f1dd047cd
--- /dev/null
+++ b/testsuite/tests/driver/fat-iface/T22807B.hs
@@ -0,0 +1,5 @@
+{-# LANGUAGE TemplateHaskell #-}
+module T22807B where
+import T22807A
+
+$(pure xs)
diff --git a/testsuite/tests/driver/fat-iface/all.T b/testsuite/tests/driver/fat-iface/all.T
index c526aa7493..a3667eee3c 100644
--- a/testsuite/tests/driver/fat-iface/all.T
+++ b/testsuite/tests/driver/fat-iface/all.T
@@ -15,5 +15,7 @@ test('fat013', [req_th, extra_files(['FatTH.hs', 'FatQuote.hs'])], multimod_comp
# When using interpreter should not produce objects
test('fat014', [req_th, extra_files(['FatTH.hs', 'FatQuote.hs']), extra_run_opts('-fno-code')], ghci_script, ['fat014.script'])
test('fat015', [req_th, unless(ghc_dynamic(), skip), extra_files(['FatQuote.hs', 'FatQuote1.hs', 'FatQuote2.hs', 'FatTH1.hs', 'FatTH2.hs', 'FatTHTop.hs'])], multimod_compile, ['FatTHTop', '-fno-code -fwrite-interface'])
+test('T22807', [req_th, expect_broken(22807), unless(ghc_dynamic(), skip), extra_files(['T22807A.hs', 'T22807B.hs'])]
+ , makefile_test, ['T22807'])