diff options
author | Daniel Rogozin <daniel.rogozin@serokell.io> | 2020-09-24 16:30:59 +0300 |
---|---|---|
committer | Daniel Rogozin <daniel.rogozin@serokell.io> | 2020-10-11 22:20:04 +0300 |
commit | 990ea991a1c35fdb894fcb91f919fb8f8fed33dd (patch) | |
tree | 6a2a2c9719e692927bcfa2cac4f832c4f12c0753 /testsuite/tests/rename | |
parent | 274e21f02fabb4b3761841972b1074d0c0146fae (diff) | |
download | haskell-990ea991a1c35fdb894fcb91f919fb8f8fed33dd.tar.gz |
Fall back to types when looking up data constructors (#18740)wip/ghc-18740-lookup-update
Before this patch, referring to a data constructor in a term-level
context led to a scoping error:
ghci> id Int
<interactive>:1:4: error: Data constructor not in scope: Int
After this patch, the renamer falls back to the type namespace
and successfully finds the Int. It is then rejected in the type
checker with a more useful error message:
<interactive>:1:4: error:
• Illegal term-level use of the type constructor ‘Int’
imported from ‘Prelude’ (and originally defined in ‘GHC.Types’)
• In the first argument of ‘id’, namely ‘Int’
In the expression: id Int
We also do this for type variables.
Diffstat (limited to 'testsuite/tests/rename')
6 files changed, 30 insertions, 2 deletions
diff --git a/testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr b/testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr index ad574a619f..8beac36a43 100644 --- a/testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr +++ b/testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr @@ -1,3 +1,7 @@ -RnStaticPointersFail02.hs:5:12: error: - Data constructor not in scope: T +RnStaticPointersFail02.hs:5:12: +Illegal term-level use of the type constructor ‘T’ + defined at RnStaticPointersFail02.hs:7:1 +In the body of a static form: T + In the expression: static T + In an equation for ‘f’: f = static T diff --git a/testsuite/tests/rename/should_fail/T18740a.hs b/testsuite/tests/rename/should_fail/T18740a.hs new file mode 100644 index 0000000000..b827dbeac8 --- /dev/null +++ b/testsuite/tests/rename/should_fail/T18740a.hs @@ -0,0 +1,3 @@ +module T18740a where + +x = Int diff --git a/testsuite/tests/rename/should_fail/T18740a.stderr b/testsuite/tests/rename/should_fail/T18740a.stderr new file mode 100644 index 0000000000..2a0463adf0 --- /dev/null +++ b/testsuite/tests/rename/should_fail/T18740a.stderr @@ -0,0 +1,7 @@ + +T18740a.hs:3:5: error: + • Illegal term-level use of the type constructor ‘Int’ + imported from ‘Prelude’ at T18740a.hs:1:8-14 + (and originally defined in ‘GHC.Types’) + • In the expression: Int + In an equation for ‘x’: x = Int diff --git a/testsuite/tests/rename/should_fail/T18740b.hs b/testsuite/tests/rename/should_fail/T18740b.hs new file mode 100644 index 0000000000..e2961093a9 --- /dev/null +++ b/testsuite/tests/rename/should_fail/T18740b.hs @@ -0,0 +1,6 @@ +{-# LANGUAGE ScopedTypeVariables #-} +module T18740b where + +import Data.Proxy + +f (Proxy :: Proxy a) = a diff --git a/testsuite/tests/rename/should_fail/T18740b.stderr b/testsuite/tests/rename/should_fail/T18740b.stderr new file mode 100644 index 0000000000..86c6c74961 --- /dev/null +++ b/testsuite/tests/rename/should_fail/T18740b.stderr @@ -0,0 +1,6 @@ + +T18740b.hs:6:24: error: + • Illegal term-level use of the type variable ‘a’ + bound at T18740b.hs:6:4 + • In the expression: a + In an equation for ‘f’: f (Proxy :: Proxy a) = a diff --git a/testsuite/tests/rename/should_fail/all.T b/testsuite/tests/rename/should_fail/all.T index 2647ac706b..e380a913ad 100644 --- a/testsuite/tests/rename/should_fail/all.T +++ b/testsuite/tests/rename/should_fail/all.T @@ -156,3 +156,5 @@ test('T17593', normal, compile_fail, ['']) test('T18145', normal, compile_fail, ['']) test('T18240a', normal, compile_fail, ['']) test('T18240b', normal, compile_fail, ['']) +test('T18740a', normal, compile_fail, ['']) +test('T18740b', normal, compile_fail, ['']) |