diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2020-04-27 17:08:19 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-04-28 15:40:42 -0400 |
commit | 518a63d4d7e31e49a81ad66d5e5ccb1f790f6de9 (patch) | |
tree | 2424d1fb4c64313a5e98f807789d575de9942f97 /testsuite | |
parent | 4b9764db7c190de377c06dfc71bfe6e4b37c7eb0 (diff) | |
download | haskell-518a63d4d7e31e49a81ad66d5e5ccb1f790f6de9.tar.gz |
Make boxed 1-tuples have known keys
Unlike other tuples, which use special syntax and are "known" by way
of a special `isBuiltInOcc_maybe` code path, boxed 1-tuples do not
use special syntax. Therefore, in order to make sure that the
internals of GHC are aware of the `data Unit a = Unit a` definition
in `GHC.Tuple`, we give `Unit` known keys. For the full details, see
`Note [One-tuples] (Wrinkle: Make boxed one-tuple names have known keys)`
in `GHC.Builtin.Types`.
Fixes #18097.
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/th/T18097.hs | 14 | ||||
-rw-r--r-- | testsuite/tests/th/all.T | 1 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_compile/holes.stderr | 1 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_compile/holes3.stderr | 1 |
4 files changed, 17 insertions, 0 deletions
diff --git a/testsuite/tests/th/T18097.hs b/testsuite/tests/th/T18097.hs new file mode 100644 index 0000000000..2263dfe018 --- /dev/null +++ b/testsuite/tests/th/T18097.hs @@ -0,0 +1,14 @@ +{-# LANGUAGE TemplateHaskell #-} +module T18097 where + +import Language.Haskell.TH +import GHC.Tuple + +f = case $( tupE [ [| "ok" |] ] ) of Unit x -> putStrLn x +g = case Unit "ok" of $( tupP [ [p| x |] ] ) -> putStrLn x + +h :: $( tupleT 1 ) String +h = Unit "ok" + +i :: Unit String +i = $( tupE [ [| "ok" |] ] ) diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T index 458b45d67f..8e747cbefa 100644 --- a/testsuite/tests/th/all.T +++ b/testsuite/tests/th/all.T @@ -502,6 +502,7 @@ test('T17511', normal, compile, ['']) test('T17608', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques']) test('T17688a', normal, compile, ['']) test('T17688b', normal, compile, ['']) +test('T18097', normal, compile, ['']) test('TH_PprStar', normal, compile, ['-v0 -dsuppress-uniques']) test('TH_StringLift', normal, compile, ['']) test('TH_BytesShowEqOrd', normal, compile_and_run, ['']) diff --git a/testsuite/tests/typecheck/should_compile/holes.stderr b/testsuite/tests/typecheck/should_compile/holes.stderr index 892f875f3c..ec5e1bf229 100644 --- a/testsuite/tests/typecheck/should_compile/holes.stderr +++ b/testsuite/tests/typecheck/should_compile/holes.stderr @@ -90,6 +90,7 @@ holes.hs:11:15: warning: [-Wtyped-holes (in -Wdefault)] Nothing :: forall a. Maybe a Just :: forall a. a -> Maybe a [] :: forall a. [a] + Unit :: forall a. a -> Unit a asTypeOf :: forall a. a -> a -> a id :: forall a. a -> a until :: forall a. (a -> Bool) -> (a -> a) -> a -> a diff --git a/testsuite/tests/typecheck/should_compile/holes3.stderr b/testsuite/tests/typecheck/should_compile/holes3.stderr index ea1f5a6c2c..fa9590663b 100644 --- a/testsuite/tests/typecheck/should_compile/holes3.stderr +++ b/testsuite/tests/typecheck/should_compile/holes3.stderr @@ -93,6 +93,7 @@ holes3.hs:11:15: error: Nothing :: forall a. Maybe a Just :: forall a. a -> Maybe a [] :: forall a. [a] + Unit :: forall a. a -> Unit a asTypeOf :: forall a. a -> a -> a id :: forall a. a -> a until :: forall a. (a -> Bool) -> (a -> a) -> a -> a |