diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2018-01-26 13:10:26 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2018-01-26 14:37:29 -0500 |
commit | 59fa7b32b018a91f81773ca676251a0b2761ef56 (patch) | |
tree | 7de1fd6fbc78e43dbae6bba706ab489b69bf27b2 /testsuite/tests/gadt | |
parent | a55d581f8f2923560c3444253050b13fdf2dec10 (diff) | |
download | haskell-59fa7b32b018a91f81773ca676251a0b2761ef56.tar.gz |
Fix #14719 by using the setting the right SrcSpan
Currently, error messages that germane to GADT constructors
put the source span at only the first character in the constructor,
leading to insufficient caret diagnostics. This can be easily fixed
by using a source span that spans the entire constructor, instead of
just the first character.
Test Plan: make test TEST=T14719
Reviewers: alanz, bgamari, simonpj
Reviewed By: alanz, simonpj
Subscribers: simonpj, goldfire, rwbarton, thomie, carter
GHC Trac Issues: #14719
Differential Revision: https://phabricator.haskell.org/D4344
Diffstat (limited to 'testsuite/tests/gadt')
-rw-r--r-- | testsuite/tests/gadt/T14719.hs | 8 | ||||
-rw-r--r-- | testsuite/tests/gadt/T14719.stderr | 18 | ||||
-rw-r--r-- | testsuite/tests/gadt/all.T | 1 |
3 files changed, 27 insertions, 0 deletions
diff --git a/testsuite/tests/gadt/T14719.hs b/testsuite/tests/gadt/T14719.hs new file mode 100644 index 0000000000..004116dcc6 --- /dev/null +++ b/testsuite/tests/gadt/T14719.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE GADTs #-} +module T14719 where + +data Foo1 where + MkFoo1 :: Bool + +newtype Foo2 where + MkFoo2 :: Foo2 diff --git a/testsuite/tests/gadt/T14719.stderr b/testsuite/tests/gadt/T14719.stderr new file mode 100644 index 0000000000..cfac00c0c0 --- /dev/null +++ b/testsuite/tests/gadt/T14719.stderr @@ -0,0 +1,18 @@ + +T14719.hs:5:3: error: + • Data constructor ‘MkFoo1’ returns type ‘Bool’ + instead of an instance of its parent type ‘Foo1’ + • In the definition of data constructor ‘MkFoo1’ + In the data type declaration for ‘Foo1’ + | +5 | MkFoo1 :: Bool + | ^^^^^^^^^^^^^^ + +T14719.hs:8:3: error: + • The constructor of a newtype must have exactly one field + but ‘MkFoo2’ has none + • In the definition of data constructor ‘MkFoo2’ + In the newtype declaration for ‘Foo2’ + | +8 | MkFoo2 :: Foo2 + | ^^^^^^^^^^^^^^ diff --git a/testsuite/tests/gadt/all.T b/testsuite/tests/gadt/all.T index c81ab80c04..59ec307d58 100644 --- a/testsuite/tests/gadt/all.T +++ b/testsuite/tests/gadt/all.T @@ -115,3 +115,4 @@ test('T9380', normal, compile_and_run, ['']) test('T12087', normal, compile_fail, ['']) test('T12468', normal, compile_fail, ['']) test('T14320', normal, compile, ['']) +test('T14719', normal, compile_fail, ['-fdiagnostics-show-caret']) |