Opened 4 years ago

Last modified 16 months ago

#7668 new bug

Location in -fdefer-type-errors

Reported by: monoidal Owned by:
Priority: normal Milestone:
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 Rev(s):
Wiki Page:

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 (7)

comment:1 Changed 4 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 4 years ago by simonpj

difficulty: 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 4 years ago by igloo

Component: CompilerCompiler (Type checker)
Milestone: 7.8.1

comment:4 Changed 3 years ago by thoughtpolice

Milestone: 7.8.37.10.1

Moving to 7.10.1

comment:5 Changed 2 years ago by thoughtpolice

Milestone: 7.10.17.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.

comment:6 Changed 21 months ago by thoughtpolice

Milestone: 7.12.18.0.1

Milestone renamed

comment:7 Changed 16 months ago by thomie

Milestone: 8.0.1
Note: See TracTickets for help on using tickets.