diff options
author | David Kraeutmann <kane@kane.cx> | 2015-07-07 16:59:52 +0200 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2015-07-07 16:59:52 +0200 |
commit | 9a3e1657db4c0292fc06d6183a802af631c3666a (patch) | |
tree | f18d0fb8619e580a69ce99c4c107bd9b43450180 /testsuite | |
parent | 31580e2c81543a58c0d352154c6109d843978cdf (diff) | |
download | haskell-9a3e1657db4c0292fc06d6183a802af631c3666a.tar.gz |
Deferred type errors now throw TypeError (#10284)
Depends on D864.
Previous behaviour was ErrorCall, which might mask issues in tests
using -fdefer-type-errors
Signed-off-by: David Kraeutmann <kane@kane.cx>
Test Plan: Test whether the error thrown is indeed TypeError and not
ErrorCall.
Reviewers: hvr, nomeata, austin
Reviewed By: nomeata, austin
Subscribers: nomeata, simonpj, thomie
Differential Revision: https://phabricator.haskell.org/D866
GHC Trac Issues: #10284
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/typecheck/should_run/T10284.hs | 17 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_run/T10284.stderr | 5 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_run/T10284.stdout | 5 | ||||
-rwxr-xr-x | testsuite/tests/typecheck/should_run/all.T | 1 |
4 files changed, 28 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_run/T10284.hs b/testsuite/tests/typecheck/should_run/T10284.hs new file mode 100644 index 0000000000..8fc86351a0 --- /dev/null +++ b/testsuite/tests/typecheck/should_run/T10284.hs @@ -0,0 +1,17 @@ +{-# OPTIONS_GHC -fdefer-type-errors -fno-warn-deferred-type-errors #-} + +import Control.Exception + +a :: Int +a = 'a' + +main :: IO () +main = do + catch (evaluate a) + (\e -> do let err = show (e :: TypeError) + putStrLn ("As expected, TypeError: " ++ err) + return "") + catch (evaluate a) + (\e -> do let err = show (e :: ErrorCall) + putStrLn ("Something went horribly wrong: " ++ err) + return "") diff --git a/testsuite/tests/typecheck/should_run/T10284.stderr b/testsuite/tests/typecheck/should_run/T10284.stderr new file mode 100644 index 0000000000..c7133f0172 --- /dev/null +++ b/testsuite/tests/typecheck/should_run/T10284.stderr @@ -0,0 +1,5 @@ +T10284: T10284.hs:14:19: error: + Couldn't match expected type ‘()’ with actual type ‘Int’ + In the first argument of ‘evaluate’, namely ‘a’ + In the first argument of ‘catch’, namely ‘(evaluate a)’ +(deferred type error) diff --git a/testsuite/tests/typecheck/should_run/T10284.stdout b/testsuite/tests/typecheck/should_run/T10284.stdout new file mode 100644 index 0000000000..ea03ec8a1a --- /dev/null +++ b/testsuite/tests/typecheck/should_run/T10284.stdout @@ -0,0 +1,5 @@ +As expected, TypeError: T10284.hs:6:5: error: + Couldn't match expected type ‘Int’ with actual type ‘Char’ + In the expression: 'a' + In an equation for ‘a’: a = 'a' +(deferred type error) diff --git a/testsuite/tests/typecheck/should_run/all.T b/testsuite/tests/typecheck/should_run/all.T index 4195ca8715..b1525bdc00 100755 --- a/testsuite/tests/typecheck/should_run/all.T +++ b/testsuite/tests/typecheck/should_run/all.T @@ -119,3 +119,4 @@ test('T9497b-run', [exit_code(1)], compile_and_run, ['-fdefer-typed-holes -fno-w test('T9497c-run', [exit_code(1)], compile_and_run, ['-fdefer-type-errors -fno-warn-typed-holes']) test('T9858c', normal, compile_and_run, ['']) test('T9858d', normal, compile_and_run, ['']) +test('T10284', exit_code(1), compile_and_run, ['']) |