Opened 9 years ago

Closed 8 years ago

Last modified 17 months ago

#919 closed bug (fixed)

Cryptic type error message (should be syntax error)

Reported by: josef.svenningsson@… Owned by:
Priority: normal Milestone: 6.8.1
Component: Compiler (Type checker) Version: 6.5
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

It seems ghc allows a syntax for types which if beyond Haskell98 even without -fglasgow-exts. Consider the following program:

destroy :: (forall a. (a -> Maybe (b,a)) -> a -> c) -> [b] -> c
destroy g xs = g listpsi xs
  where listpsi :: [a] -> Maybe (a,[a])
        listpsi [] = Nothing
        listpsi (x:xs) = Just (x,xs)

It gives the following rather cryptic error message without -fglasgow-exts:

ConcatMap.hs:7:17:
    Couldn't match expected type `.' (a rigid variable)
           against inferred type `(->)'
      `.' is bound by the type signature for `destroy'
        at ConcatMap.hs:6:20
    Probable cause: `listpsi' is applied to too few arguments
    In the first argument of `g', namely `listpsi'
    In the expression: g listpsi xs

The fact that ghc interpreted `.' as a type variable baffeled me for a moment. I would expect ghc to report a syntax error since the type is not syntactically Haskell98.

Change History (8)

comment:1 Changed 9 years ago by igloo

  • Component changed from Compiler to Compiler (Type checker)
  • difficulty changed from Unknown to Easy (1 hr)
  • Milestone set to 6.8

Haskell 98 indeed does not seem to allow operators as types, so we ought not allow this without -fglasgow-exts. Too late for 6.6, though...

comment:2 Changed 9 years ago by simonpj

Fixed thank you. Test is tcfail166

Simon

comment:3 Changed 8 years ago by simonmar

  • Resolution set to fixed
  • Status changed from new to closed

Definitely fixed, error is now:

919.hs:1:20:
    Illegal operator `.' in type `forall a . ((a -> Maybe (b, a))
                                              -> a -> c)'
      (Use -XTypeOperators to allow operators in types)

comment:4 Changed 8 years ago by igloo

  • Milestone changed from 6.8 branch to 6.8.1

comment:5 Changed 7 years ago by simonmar

  • Architecture changed from Unknown to Unknown/Multiple

comment:6 Changed 7 years ago by simonmar

  • Operating System changed from Unknown to Unknown/Multiple

comment:7 Changed 6 years ago by simonmar

  • difficulty changed from Easy (1 hr) to Easy (less than 1 hour)

comment:8 Changed 17 months ago by simonpj <simonpj@…>

Note: See TracTickets for help on using tickets.