[GHC] #10079: Coercible solver regression: Couldn't match rep of () with Const () b

GHC ghc-devs at haskell.org
Wed Feb 11 11:58:30 UTC 2015


#10079: Coercible solver regression: Couldn't match rep of () with Const () b
-------------------------------------+-------------------------------------
        Reporter:  glguy             |                   Owner:  goldfire
            Type:  bug               |                  Status:  new
        Priority:  highest           |               Milestone:  7.10.1
       Component:  Compiler (Type    |                 Version:  7.10.1-rc1
  checker)                           |                Keywords:
      Resolution:                    |            Architecture:
Operating System:  Unknown/Multiple  |  Unknown/Multiple
 Type of failure:  GHC rejects       |               Test Case:
  valid program                      |                Blocking:
      Blocked By:                    |  Differential Revisions:
 Related Tickets:                    |
-------------------------------------+-------------------------------------
Changes (by simonpj):

 * owner:   => goldfire


Comment:

 Richard, this is in your bailiwick.  The problem is in `TcCanonical`:
 {{{
 -- When working with ReprEq, unwrap newtypes next.
 -- Otherwise, a ~ Id a wouldn't get solved
 can_eq_nc' rdr_env envs ev ReprEq ty1 _ ty2 ps_ty2
   | Just (co, ty1') <- tcTopNormaliseNewTypeTF_maybe envs rdr_env ty1
   = can_eq_newtype_nc rdr_env ev NotSwapped co ty1 ty1' ty2 ps_ty2
 can_eq_nc' rdr_env envs ev ReprEq ty1 ps_ty1 ty2 _
   | Just (co, ty2') <- tcTopNormaliseNewTypeTF_maybe envs rdr_env ty2
   = can_eq_newtype_nc rdr_env ev IsSwapped  co ty2 ty2' ty1 ps_ty1
 }}}
 This is done before flattening. At that stage the constaint looks like
 `Coercible a (f b)`, but we already know `a := ()` `f := Const ()`, so the
 equation doesn't match.  But then we don't see the newtype expansion at
 all.

 I suppose we have to flatten ''before'' trying the newtype expansion.
 Which is a bit awkward in practice.

 I suspect that we should have a new invariant for `CTyEqCan`, that in
 canonical constraint `a ~R ty`, the rhs `ty` is never a saturated newtype
 application.  And then enforce that invariant.

 That would deal with the `CTyEqCan` case.  Then we need to do something in
 `try_decompose_repr_app`.  (Acutally that function looks wrong to me.
 Suppose we had `f Age ~R g Int`.  Then if `f` and `g` both flattened to
 `Maybe` we should decompose, not fail.)

 This is an outright bug; must fix for 7.10.

 Simon

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10079#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list