Skip to content
  • Simon Peyton Jones's avatar
    Fix newtype deriving properly (un-doing Audreys patch) · 171d4582
    Simon Peyton Jones authored
    The newtype-deriving mechanism generates a HsSyn case expression looking
    like this
    	case (d `cast` co) of { ... }
    That is, the case expression scrutinises a dictionary.  This is 
    otherwise never seen in HsSyn, and it made the desugarer
    (Check.get_unused_cons) crash in tcTyConAppTyCon.
    
    It would really be better to generate Core in TcInstDecls (the newtype
    deriving part) but I'm not going to do that today.  Instead, I made
    Check.get_unused_cons a bit more robust.
    
    Audrey tried to fix this over the weekend, but her fix was, alas, utterly
    bogus, which caused mysterious failures later.  I completely undid this
    change.
    
    Anyway it should work now!
    171d4582