summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorSebastian Graf <sebastian.graf@kit.edu>2021-10-21 17:17:45 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-10-22 19:22:31 -0400
commitdd2dba808aaa957c3d036b0025b412c499aace3d (patch)
tree8ecf5f2a4b9b946ea878786ab101e668aedcfa19 /testsuite
parent621608c990d01dd35cb2c4fb8fc49089bef81d57 (diff)
downloadhaskell-dd2dba808aaa957c3d036b0025b412c499aace3d.tar.gz
WorkWrap: `isRecDataCon` should not eta-reduce NewTyCon field tys (#20539)
In #20539 we had a type ```hs newtype Measured a = Measured { unmeasure :: () -> a } ``` and `isRecDataCon Measured` recursed into `go_arg_ty` for `(->) ()`, because `unwrapNewTyConEtad_maybe` eta-reduced it. That triggered an assertion error a bit later. Eta reducing the field type is completely wrong to do here! Just call `unwrapNewTyCon_maybe` instead. Fixes #20539 and adds a regression test T20539.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/cpranal/should_compile/T20539.hs7
-rw-r--r--testsuite/tests/cpranal/should_compile/all.T2
2 files changed, 8 insertions, 1 deletions
diff --git a/testsuite/tests/cpranal/should_compile/T20539.hs b/testsuite/tests/cpranal/should_compile/T20539.hs
new file mode 100644
index 0000000000..a2943cf91e
--- /dev/null
+++ b/testsuite/tests/cpranal/should_compile/T20539.hs
@@ -0,0 +1,7 @@
+module T20593 where
+
+newtype Measured a = Measured { unmeasure :: () -> a }
+data Subdiagram = Subdiagram () (Measured ())
+
+mkSubdiagram :: () -> Subdiagram
+mkSubdiagram d = Subdiagram d (Measured (\_ -> ()))
diff --git a/testsuite/tests/cpranal/should_compile/all.T b/testsuite/tests/cpranal/should_compile/all.T
index 03d2b10d68..f33b43fe3a 100644
--- a/testsuite/tests/cpranal/should_compile/all.T
+++ b/testsuite/tests/cpranal/should_compile/all.T
@@ -21,4 +21,4 @@ test('T18401', [ grep_errmsg(r'^T18401\.\S+ ::') ], compile, ['-ddump-simpl -dsu
# It won't match if the Cpr=1 is missing, which is what we're trying to assess.
test('T18824', [ grep_errmsg(r'JoinId[^\n]*Cpr') ], compile, ['-ddump-exitify -dppr-cols=1000 -dsuppress-uniques'])
-
+test('T20539', [], compile, ['']) # simply should not crash