diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2019-08-28 13:40:10 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-09-13 03:10:26 -0400 |
commit | 5b64aee2336c4f7a125c26b5b7a9d9e7a12899ec (patch) | |
tree | 2c30d8be7acf60c731362d60cfd170e3f12ac483 /testsuite | |
parent | a733002a53d0903180f7bba9ecbb499e1afa60e0 (diff) | |
download | haskell-5b64aee2336c4f7a125c26b5b7a9d9e7a12899ec.tar.gz |
Fix scoping of implicit parameters
There was an outright bug in TcInteract.solveOneFromTheOther
which meant that we did not always pick the innermost
implicit parameter binding, causing #17104.
The fix is easy, just a rearrangement of conditional tests
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/typecheck/should_run/T17104.hs | 24 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_run/T17104.stdout | 1 | ||||
-rwxr-xr-x | testsuite/tests/typecheck/should_run/all.T | 1 |
3 files changed, 26 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_run/T17104.hs b/testsuite/tests/typecheck/should_run/T17104.hs new file mode 100644 index 0000000000..8cf3b5fda1 --- /dev/null +++ b/testsuite/tests/typecheck/should_run/T17104.hs @@ -0,0 +1,24 @@ +{-# LANGUAGE ImplicitParams #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TypeOperators #-} + +module Main where + +import GHC.Exts +import Data.Type.Equality + +type family F x :: Constraint +type instance F Int = (?x :: String) + +data Box where MkBox :: (?x :: String) => Box +data Box2 a where MkBox2 :: F a => Box2 a + +f :: Box2 a -> Box -> a :~: Int -> String +f MkBox2 MkBox Refl = ?x + +main :: IO () +main = do { let mb = let ?x = "right" in MkBox + ; let mb2 = let ?x = "wrong" in MkBox2 + ; print (f mb2 mb Refl) } diff --git a/testsuite/tests/typecheck/should_run/T17104.stdout b/testsuite/tests/typecheck/should_run/T17104.stdout new file mode 100644 index 0000000000..f2bb7441cf --- /dev/null +++ b/testsuite/tests/typecheck/should_run/T17104.stdout @@ -0,0 +1 @@ +"right" diff --git a/testsuite/tests/typecheck/should_run/all.T b/testsuite/tests/typecheck/should_run/all.T index 05fddcb0b0..512362f1bb 100755 --- a/testsuite/tests/typecheck/should_run/all.T +++ b/testsuite/tests/typecheck/should_run/all.T @@ -140,3 +140,4 @@ test('UnliftedNewtypesFamilyRun', normal, compile_and_run, ['']) test('UnliftedNewtypesDependentFamilyRun', normal, compile_and_run, ['']) test('UnliftedNewtypesIdentityRun', normal, compile_and_run, ['']) test('UnliftedNewtypesCoerceRun', normal, compile_and_run, ['']) +test('T17104', normal, compile_and_run, ['']) |