[GHC] #10619: Order matters when type-checking
#10619: Order matters when type-checking -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- When I say {{{ {-# LANGUAGE RankNTypes #-} module Bug where foo True = (\x -> x) :: (forall a. a -> a) -> forall b. b -> b foo False = \y -> y }}} the module compiles. But when I say {{{ {-# LANGUAGE RankNTypes #-} module Bug where foo False = \y -> y foo True = (\x -> x) :: (forall a. a -> a) -> forall b. b -> b }}} it doesn't, failing with {{{ Bug.hs:6:13: Couldn't match type ‘b0 -> b0’ with ‘forall a. a -> a’ Expected type: (forall a. a -> a) -> forall a. a -> a Actual type: (forall a. a -> a) -> b0 -> b0 In the expression: (\ x -> x) :: (forall a. a -> a) -> forall b. b -> b In an equation for ‘foo’: foo True = (\ x -> x) :: (forall a. a -> a) -> forall b. b -> b }}} I believe this behavior stems from the special case in `tcMonoBinds`, for non-recursive functions without a type signature. I believe the bug would be fixed if that function also checks to make sure that there is precisely one clause to the function. Do you agree? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10619> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#10619: Order matters when type-checking -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by goldfire): It gets worse. The same problem happens between these two: This succeeds: {{{ {-# LANGUAGE RankNTypes #-} module Bug where foo _ = if True then ((\x -> x) :: (forall a. a -> a) -> forall b. b -> b) else \y -> y }}} This fails: {{{ foo _ = if True then \y -> y else ((\x -> x) :: (forall a. a -> a) -> forall b. b -> b) }}} But the cause is different. This second case is caused by the fact that `ReturnTv`s can unify with polytypes, and the `ReturnTv` for the whole expression is just pushed into the `if`'s branches. But even if the `ReturnTv` were replaced by a `TauTv` before pushing into the `if`'s branches, it would ''still'' be broken because a `TauTv` with an !OpenKind can also unify with polytypes. I think the solution for this case is to create a new flavor of `TauTv` that truly insists on being a tau-type. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10619#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#10619: Order matters when type-checking -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by jstolarek): * cc: jstolarek (added) -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10619#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#10619: Order matters when type-checking -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): -------------------------------------+------------------------------------- Comment (by Richard Eisenberg <eir@…>): In [changeset:"2db18b8135335da2da9918b722699df684097be9/ghc" 2db18b81/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="2db18b8135335da2da9918b722699df684097be9" Visible type application This re-working of the typechecker algorithm is based on the paper "Visible type application", by Richard Eisenberg, Stephanie Weirich, and Hamidhasan Ahmed, to be published at ESOP'16. This patch introduces -XTypeApplications, which allows users to say, for example `id @Int`, which has type `Int -> Int`. See the changes to the user manual for details. This patch addresses tickets #10619, #5296, #10589. }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10619#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#10619: Order matters when type-checking -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): -------------------------------------+------------------------------------- Comment (by Richard Eisenberg <eir@…>): In [changeset:"05e35414219c29d2eaf4bb29b6dd6fb8a8388e9b/ghc" 05e3541/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="05e35414219c29d2eaf4bb29b6dd6fb8a8388e9b" Test #10619 in typecheck/should_fail/T10619 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10619#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#10619: Order matters when type-checking -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | typecheck/should_fail/T10619 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by goldfire): * testcase: => typecheck/should_fail/T10619 * status: new => closed * resolution: => fixed -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10619#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#10619: Order matters when type-checking -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.1 Resolution: fixed | Keywords: | ImpredicativeTypes Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | typecheck/should_fail/T10619 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * keywords: => ImpredicativeTypes -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10619#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC