Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#10495 closed bug (fixed)

Poor error message for Coercible constraint unsatisfiability

Reported by: goldfire Owned by: goldfire
Priority: normal Milestone: 7.10.3
Component: Compiler Version: 7.10.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: typecheck/should_fail/T10495
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

If I say

import Data.Coerce

foo = coerce

I get

    Couldn't match representation of type ‘a0’ with that of ‘b0’
      ‘a0’ is untouchable
        inside the constraints: ()
        bound by the inferred type of foo :: a0 -> b0
        at /Users/rae/temp/bug/App.hs:3:1-12
    Relevant bindings include
      foo :: a0 -> b0 (bound at /Users/rae/temp/bug/App.hs:3:1)
    In the expression: coerce
    In an equation for ‘foo’: foo = coerce

How awful. Eta-expanding foo works fine, though.

Change History (6)

comment:1 Changed 4 years ago by simonpj

Try NonMonmorphismRestriction; works fine. This is just the MR biting. I'm not sure there is much we can do here.

Simon

comment:2 Changed 4 years ago by goldfire

Yes; I realized that soon after posting the ticket. But the error message is terrible -- there's nothing about untouchable variables here. A fix to the error message is on the way.

comment:3 Changed 4 years ago by Richard Eisenberg <eir@…>

In 0de0b14691e0b0789988332ad5addc2a31b09ba6/ghc:

Fix #10495.

This change means that the intricate reasoning in TcErrors
around getting messages just right for nominal equalities
is skipped for representational equalities.

comment:4 Changed 4 years ago by goldfire

Milestone: 7.10.3
Status: newmerge
Summary: Total inability to infer type for coercePoor error message for Coercible constraint unsatisfiability
Test Case: typecheck/should_fail/T10495

Merge (into 7.10.3) if convenient. This is just about error messages, so not very important.

comment:5 Changed 4 years ago by bgamari

Version: 7.117.10.1

The reference to untouchable variables appeared in 7.10.1.

comment:6 Changed 4 years ago by bgamari

Resolution: fixed
Status: mergeclosed

This was merged to ghc-7.10.

Last edited 4 years ago by bgamari (previous) (diff)
Note: See TracTickets for help on using tickets.