Opened 2 years ago

Last modified 4 months ago

#7668 new bug

Location in -fdefer-type-errors

Reported by: monoidal Owned by:
Priority: normal Milestone: 7.12.1
Component: Compiler (Type checker) Version: 7.6.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

Consider

x :: Char
x = 'x' + 1

y :: Char
y = 'y' + 1

Run ghci -fdefer-type-errors:

*Main> x
*** Exception: G.hs:5:9:
    No instance for (Num Char) arising from a use of `+'
    In the expression: 'y' + 1
    In an equation for `y': y = 'y' + 1
(deferred type error)
*Main> y
*** Exception: G.hs:5:9:
    No instance for (Num Char) arising from a use of `+'
    In the expression: 'y' + 1
    In an equation for `y': y = 'y' + 1
(deferred type error)

The first exception is wrong. It seems that the missing Num Char instance is filled with the same error message in all places where the constraint should be supplied.

Change History (5)

comment:1 Changed 2 years ago by monoidal

Or even:

x :: Char
x = 'x' - 1

y :: Char
y = 'y' + 1

both messages say No instance for (Num Char) arising from a use of `+'.

comment:2 Changed 2 years ago by simonpj

  • difficulty set to Unknown

Yes, that's a good point. It happens becuase the constraint solver "commons up" equal constraints. I suppose it could not do that when you have -fdefer-type-errors, but that would make the parts of the code that are perfectly ok have less sharing.

I don't see an easy way to fix this. I'll just leave it open and see how pressing it seems in practice.

Simon

comment:3 Changed 2 years ago by igloo

  • Component changed from Compiler to Compiler (Type checker)
  • Milestone set to 7.8.1

comment:4 Changed 12 months ago by thoughtpolice

  • Milestone changed from 7.8.3 to 7.10.1

Moving to 7.10.1

comment:5 Changed 4 months ago by thoughtpolice

  • Milestone changed from 7.10.1 to 7.12.1

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

Note: See TracTickets for help on using tickets.