Opened 4 years ago

Last modified 9 months ago

#11384 new bug

Error says to fix incorrect return type

Reported by: Iceland_jack Owned by:
Priority: normal Milestone: 8.10.1
Component: Compiler (Type checker) Version: 7.6.3
Keywords: GADTs, TypeErrorMessages Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect warning at compile-time Test Case:
Blocked By: #8258 Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

Defining a constructor that returns the wrong type (non-parent type).

If the constructor is not fully-applied or over-saturated GHC reports an error, instead of telling the developer to change the return type:

Prelude> data A
Prelude> data B a where MkB :: A ()

<interactive>:2:23: error:
    • Expecting one fewer argument to ‘A’
      Expected kind ‘* -> *’, but ‘A’ has kind ‘*’
    • In the type ‘A ()’
      In the definition of data constructor ‘MkB’
      In the data declaration for ‘B’

Expected:

  1. Suggest GADTs:
    • Illegal generalised algebraic data declaration for ‘B’
        (Use GADTs to allow GADTs)
    • In the data declaration for ‘B’
    
  2. Complain about incorrect return type:
    • Data constructor ‘MkB’ returns type ‘A’ 
        instead of an instance of its parent type ‘B a’
    • In the definition of data constructor ‘MkB’
      In the data type declaration for ‘B’
    

It shouldn't suggest the user fix the incorrect return type

Change History (6)

comment:1 Changed 4 years ago by thomie

Blocked By: 8258 added
Type of failure: None/UnknownIncorrect warning at compile-time
Version: 8.17.6.3

Good idea.

#8258 would help with the first suggestion (enabling GADTs).

comment:2 Changed 2 years ago by dfeuer

Component: CompilerCompiler (Type checker)
Milestone: 8.4.1

comment:3 Changed 2 years ago by simonpj

Keywords: TypeErrorMessages added

comment:4 Changed 20 months ago by bgamari

Milestone: 8.4.18.6.1

This ticket won't be resolved in 8.4; remilestoning for 8.6. Do holler if you are affected by this or would otherwise like to work on it.

comment:5 Changed 15 months ago by bgamari

Milestone: 8.6.18.8.1

These won't be fixed for 8.6, bumping to 8.8.

comment:6 Changed 9 months ago by osa1

Milestone: 8.8.18.10.1

Bumping milestones of low-priority tickets.

Note: See TracTickets for help on using tickets.