Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 5,349
    • Issues 5,349
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 572
    • Merge requests 572
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #10619
Closed
Open
Issue created Jul 08, 2015 by Richard Eisenberg@raeDeveloper

Order matters when type-checking

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?

Trac metadata
Trac field Value
Version 7.10.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking