Opened 15 months ago

Last modified 12 months ago

#7668 new bug

Location in -fdefer-type-errors

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

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

comment:1 Changed 15 months 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 14 months 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 12 months ago by igloo

  • Component changed from Compiler to Compiler (Type checker)
  • Milestone set to 7.8.1
Note: See TracTickets for help on using tickets.