Ticket #674 (closed feature request: wontfix)

Opened 7 years ago

Last modified 5 years ago

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

Changed 7 years ago by simonmar

  • status changed from new to closed
  • resolution set to wontfix

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

Changed 7 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.

Changed 7 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

Changed 5 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

Changed 5 years ago by simonmar

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