Ticket #1072 (closed bug: fixed)

Opened 5 years ago

Last modified 4 years ago

Core Lint Errors: in result of Desugar

Reported by: guest Owned by: simonpj
Priority: normal Milestone: 6.8.2
Component: Compiler Version: 6.7
Keywords: Cc:
Operating System: Windows Architecture: x86
Type of failure: Difficulty: Unknown
Test Case: tc239 Blocked By:
Blocking: Related Tickets:

Description (last modified by simonpj) (diff)

This error happens with ghc --make, so two source files are attached. To reproduce the error:

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

G:\>cd ghcError

G:\ghcError>ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.6

G:\ghcError>ghc -dcore-lint --make Main.hs
[1 of 2] Compiling WrapIOMonad      ( WrapIOMonad.hs, WrapIOMonad.o )
[2 of 2] Compiling Main             ( Main.hs, Main.o )
*** Core Lint Errors: in result of Desugar ***
{-# LINE 11 "Main.hs #-}:
    [RHS of f2_aGA :: WrapIOMonad.WrapIO2 a_aGz]
    The type of this binder doesn't match the type of its RHS: f2_aGA
    Binder's type: WrapIOMonad.WrapIO2 a_aGz
    Rhs type: WrapIOMonad.WrapIO GHC.Base.String a_aGz
*** Offending Program ***
Rec {
:Main.main :: GHC.IOBase.IO ()
[Exported]
[]
:Main.main = GHC.TopHandler.runMainIO @ () Main.main
Main.main :: GHC.IOBase.IO ()
[Exported]
[]
Main.main = GHC.Err.undefined @ (GHC.IOBase.IO ())
main_aGK :: GHC.IOBase.IO ()
[]
main_aGK = Main.main
Main.f2 :: forall a_aB9. (GHC.Show.Show a_aB9) => WrapIOMonad.WrapIO2 a_aB9
[]
Main.f2 =
  \ (@ a_aGz) ($dShow_aGD :: {GHC.Show.Show a_aGz}) ->
    __letrec {
      f2_aGA :: WrapIOMonad.WrapIO2 a_aGz
      []
      f2_aGA = f1_aGB;
      $dShow_aGI :: {GHC.Show.Show a_aGz}
      []
      $dShow_aGI = $dShow_aGD;
      f1_aGB :: WrapIOMonad.WrapIO GHC.Base.String a_aGz
      []
      f1_aGB = Main.f1 @ a_aGz @ GHC.Base.String $dShow_aGI;
    } in  f2_aGA
Main.f1 :: forall a_aBb e_aBc.
           (GHC.Show.Show a_aBb) =>
           WrapIOMonad.WrapIO e_aBc a_aBb
[]
Main.f1 =
  \ (@ a_aGf) (@ e_aGg) ($dShow_aGq :: {GHC.Show.Show a_aGf}) ->
    __letrec {
      f1_aGh :: WrapIOMonad.WrapIO e_aGg a_aGf
      []
      f1_aGh = return_aGm @ a_aGf (GHC.Err.undefined @ a_aGf);
      $dMonad_aGv :: {GHC.Base.Monad (WrapIOMonad.WrapIO e_aGg)}
      []
      $dMonad_aGv = WrapIOMonad.$f1 @ e_aGg;
      return_aGm :: forall a_awE. a_awE -> WrapIOMonad.WrapIO e_aGg a_awE
      []
      return_aGm = GHC.Base.return @ (WrapIOMonad.WrapIO e_aGg) $dMonad_aGv;
    } in  f1_aGh
end Rec }

*** End of Offense ***


<no location info>:
Compilation had errors
G:\ghcError>

Attachments

Main.hs Download (149 bytes) - added by guest 5 years ago.
WrapIOMonad.hs Download (318 bytes) - added by guest 5 years ago.

Change History

Changed 5 years ago by guest

Changed 5 years ago by guest

Changed 5 years ago by simonpj

  • description modified (diff)

Changed 5 years ago by simonpj

  • owner set to simonpj
  • version changed from 6.6 to 6.7
  • severity changed from normal to minor

Excellent example. This is the same problem as the failure in maessen_hashtab. It's also closely related to #930

Here's what is happening (mainly notes to me). The newtype for WrapIOMonad is getting "trimmed" by TidyPgm; but occurrences of WrapIOMonad in the types of Ids are *not* trimmed. Then when we compare types, the comparing function (Type.coreEqType) looks through the newtype on one side but not the other.

I've made a temporary solution for GHC 6.6, by making coreEqType first expand synonyms and notes, then look for equal TyCons, then expand newtypes. But it's a hack, and can be fooled (by nested newtypes, for example). The hack is enough to make this program work, however.

The HEAD has a different solution: do not make newtypes transparent at all. I think that works ok, but I'm still uneasy about the fact that a given TyCon can appear in two different forms in the same compilation. So I'm going to leave this open, but at low priority.

Changed 5 years ago by igloo

  • milestone set to 6.8

Changed 5 years ago by simonpj

  • status changed from new to closed
  • testcase set to tc239
  • resolution set to fixed

I'm closing this, since it works fine now, but adding a test (tc239) so we'll know if it pops up again.

Simon

Changed 4 years ago by igloo

  • milestone changed from 6.8 branch to 6.8.2
Note: See TracTickets for help on using tickets.