summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck
diff options
context:
space:
mode:
authorSebastian Graf <sgraf1337@gmail.com>2019-10-15 13:10:14 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-10-16 07:06:20 -0400
commit6ede355422086b1430c8dff9ad0702b8e96173fe (patch)
tree9e4de9cd0d9976a9547d9e403002262c5179d246 /testsuite/tests/typecheck
parent1964195776d83c621817a75744bc7fe3f46961c9 (diff)
downloadhaskell-6ede355422086b1430c8dff9ad0702b8e96173fe.tar.gz
Infer rho-types instead of sigma-types in guard BindStmts and TransStmts
In #17343 we saw that we didn't handle the pattern guard `!_ <- undefined` correctly: The `undefined` was never evaluated. Indeed, elaboration failed to insert the invisible type aruments to `undefined`. So `undefined` was trivially a normal-form and in turn never entered. The problem is that we used to infer a sigma-type for the RHS of the guard, the leading qualifiers of which will never be useful in a pattern match situation. Hence we infer a rho-type now. Fixes #17343.
Diffstat (limited to 'testsuite/tests/typecheck')
-rw-r--r--testsuite/tests/typecheck/should_compile/T17343.hs8
-rw-r--r--testsuite/tests/typecheck/should_compile/T17343.stderr4
-rw-r--r--testsuite/tests/typecheck/should_compile/all.T1
3 files changed, 13 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_compile/T17343.hs b/testsuite/tests/typecheck/should_compile/T17343.hs
new file mode 100644
index 0000000000..e3179b4e23
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/T17343.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE BangPatterns #-}
+
+h :: ()
+h | !_ <- undefined = ()
+{-# NOINLINE h #-}
+
+-- main is expected to crash
+main = print h
diff --git a/testsuite/tests/typecheck/should_compile/T17343.stderr b/testsuite/tests/typecheck/should_compile/T17343.stderr
new file mode 100644
index 0000000000..044fa41d77
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/T17343.stderr
@@ -0,0 +1,4 @@
+T17343: Prelude.undefined
+CallStack (from HasCallStack):
+ error, called at libraries/base/GHC/Err.hs:79:14 in base:GHC.Err
+ undefined, called at T17343.hs:4:5 in main:Main
diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T
index 7594265db6..c51ff0b36b 100644
--- a/testsuite/tests/typecheck/should_compile/all.T
+++ b/testsuite/tests/typecheck/should_compile/all.T
@@ -692,3 +692,4 @@ test('T17067', normal, compile, [''])
test('T17202', expect_broken(17202), compile, [''])
test('T15839a', normal, compile, [''])
test('T15839b', normal, compile, [''])
+test('T17343', exit_code(1), compile_and_run, [''])