Opened 12 years ago

Closed 12 years ago

Last modified 9 years ago

#674 closed feature request (wontfix)

Bad error message: varying arguments

Reported by: guest Owned by:
Priority: normal Milestone:
Component: Compiler (Type checker) Version: 6.4.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

A function definition like

f :: Maybe () -> Char
f Nothing = 'a'
f Just () = 'b'

yields the error message

Varying number of arguments for function `f'

under 6.4.1 (pointing to the line with Nothing as containing the error). The following error message would be easier to understand for beginners (pointing to the line with Just):

The type signature for f specifies that the function should take one argument, but you have given it two arguments.

Change History (5)

comment:1 Changed 12 years ago by simonmar

Resolution: wontfix
Status: newclosed

The error message is correct: the two equations for f have differing numbers of arguments.

comment:2 Changed 12 years ago by guest

The error message is indeed correct, but hard to understand for newbies (I've observed this in practice, several times). In the wake of the GHC survey Simon PJ asked for error messages that could be improved. This is such an error message.

comment:3 Changed 12 years ago by simonpj

'guest' writes "In the wake of the GHC survey Simon PJ asked for error messages that could be improved. This is such an error message."

And indeed I have improved it:

Foo4.hs:4:0:
    Equations for `f' have different numbers of arguments
      Foo4.hs:4:0-14
      Foo4.hs:5:0-14

It's nothing to do with the type signature, which might be absent, or might have more args than the defintion.

Simon

comment:4 Changed 9 years ago by simonmar

Architecture: UnknownUnknown/Multiple

comment:5 Changed 9 years ago by simonmar

Operating System: UnknownUnknown/Multiple
Note: See TracTickets for help on using tickets.