[Git][ghc/ghc][wip/sjakobi/regression-tests-3] Add regression test for #10381
Simon Jakobi pushed to branch wip/sjakobi/regression-tests-3 at Glasgow Haskell Compiler / GHC Commits: 8490e918 by Simon Jakobi at 2026-03-08T17:44:55+01:00 Add regression test for #10381 Closes #10381. - - - - - 2 changed files: - + testsuite/tests/rebindable/T10381.hs - testsuite/tests/rebindable/all.T Changes: ===================================== testsuite/tests/rebindable/T10381.hs ===================================== @@ -0,0 +1,43 @@ +{-# LANGUAGE RebindableSyntax, RankNTypes #-} + +module T10381 where + +import Prelude ( String, undefined ) + +newtype Cont r a = Cont { runCont :: (forall i. a i -> r) -> r } + +(>>=) :: Cont r a -> (forall i. a i -> Cont r b) -> Cont r b +ma >>= fmb + = Cont (\k -> runCont ma (\a -> runCont (fmb a) k)) + +fail :: String -> Cont r a +fail = undefined + +return :: a i -> Cont r a +return x = Cont (\k -> k x) + +foo :: Cont r [] +foo = do + bar <- foo + return bar + +{- Previously, GHC used to reject this program with: + + Couldn't match type ‘i0’ with ‘i’ + because type variable ‘i’ would escape its scope + This (rigid, skolem) type variable is bound by + a type expected by the context: [i] -> Cont r [] + at Bug.hs:21:3-12 + Expected type: Cont r [] -> ([i0] -> Cont r []) -> Cont r [] + Actual type: Cont r [] + -> (forall i. [i] -> Cont r []) -> Cont r [] + In a stmt of a 'do' block: bar <- foo + In the expression: + do { bar <- foo; + return bar } + In an equation for ‘foo’: + foo + = do { bar <- foo; + return bar } +-} + ===================================== testsuite/tests/rebindable/all.T ===================================== @@ -35,6 +35,7 @@ test('T4851', normal, compile, ['']) test('T5908', normal, compile, ['']) test('T10112', normal, compile, ['']) +test('T10381', normal, compile, ['']) test('T11216', normal, compile, ['']) test('T11216A', normal, compile, ['']) test('T12080', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8490e91890ba3d4f5627edf6e4dbebe5... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8490e91890ba3d4f5627edf6e4dbebe5... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Simon Jakobi (@sjakobi2)