Opened 8 years ago

Closed 8 years ago

Last modified 6 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: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

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 8 years ago by simonmar

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

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

comment:2 Changed 8 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 8 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 6 years ago by simonmar

  • Architecture changed from Unknown to Unknown/Multiple

comment:5 Changed 6 years ago by simonmar

  • Operating System changed from Unknown to Unknown/Multiple
Note: See TracTickets for help on using tickets.