Opened 6 years ago

Closed 6 years ago

#3391 closed bug (fixed)

Generics compilation failure in combination with Data.Accessor deriving

Reported by: darchon Owned by: simonpj
Priority: normal Milestone:
Component: Compiler Version: 6.11
Keywords: Generics Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Test Case: typecheck/should_compile/T3391
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

When trying to compile (using my latest build: 6.11.20090722) a file with -XGenerics I get the following error:

"inplace/bin/ghc-stage2"  -O -H64m    -package-name clash-0.1 -hide-all-packages -i 
-ilibraries/clash-lib/cλash/. -ilibraries/clash-lib/cλash/dist-install/build 
-ilibraries/clash-lib/cλash/dist-install/build/autogen -Ilibraries/clash-lib/cλash/dist-install/build 
-Ilibraries/clash-lib/cλash/dist-install/build/autogen -Ilibraries/clash-lib/cλash/.   
-optP-include -optPlibraries/clash-lib/cλash/dist-install/build/autogen/cabal_macros.h 
-package base-4.1.0.0 -package containers-0.2.0.1 -package data-accessor-0.2.1 
-package data-accessor-template-0.2.1.1 -package filepath-1.1.0.1 -package ghc-6.11.20090722 
-package haskell98-1.0.1.0 -package pretty-1.0.1.0 -package prettyclass-1.0.0.0 -package syb-0.1.0.0 
-package template-haskell-2.4.0.0 -package transformers-0.1.4.0 -package vhdl-0.1   -O2 -XGenerics 
-fno-warn-deprecated-flags -Wwarn     -odir libraries/clash-lib/cλash/dist-install/build 
-hidir libraries/clash-lib/cλash/dist-install/build -stubdir libraries/clash-lib/cλash/dist-install/build 
-hisuf hi -osuf  o -hcsuf hc -c libraries/clash-lib/cλash/./CLasH/VHDL/VHDLTypes.hs 
-o libraries/clash-lib/cλash/dist-install/build/CLasH/VHDL/VHDLTypes.o

... Loading some packages etc etc. ...

/var/folders/wh/whtzeDfoGBCCu-65jmvmZU+++TI/-Tmp-/ghc58528_0/ghc58528_0.s:4565:0:
    FATAL:Symbol _clashzm0zi1_CLasHziVHDLziVHDLTypes_zdgfromVHDLState_closure already defined.
gmake[1]: *** [libraries/clash-lib/cλash/dist-install/build/CLasH/VHDL/VHDLTypes.o] Error 1
gmake: *** [all] Error 2

Indeed, when I compile with -dcore-lint I get to see this:

*** Core Lint Errors: in result of Desugar ***
<no location info>:
    Duplicate variables brought into scope
      [[CLasH.VHDL.VHDLTypes.$gfromTypeState,
        CLasH.VHDL.VHDLTypes.$gfromTypeState,
        CLasH.VHDL.VHDLTypes.$gfromTypeState],
       [CLasH.VHDL.VHDLTypes.$gtoTypeState,
        CLasH.VHDL.VHDLTypes.$gtoTypeState,
        CLasH.VHDL.VHDLTypes.$gtoTypeState],
       [CLasH.VHDL.VHDLTypes.$gfromEntity,
        CLasH.VHDL.VHDLTypes.$gfromEntity,
        CLasH.VHDL.VHDLTypes.$gfromEntity],
       [CLasH.VHDL.VHDLTypes.$gtoEntity, CLasH.VHDL.VHDLTypes.$gtoEntity,
        CLasH.VHDL.VHDLTypes.$gtoEntity],
       [CLasH.VHDL.VHDLTypes.$gfromOrdType,
        CLasH.VHDL.VHDLTypes.$gfromOrdType,
        CLasH.VHDL.VHDLTypes.$gfromOrdType],
       [CLasH.VHDL.VHDLTypes.$gtoOrdType,
        CLasH.VHDL.VHDLTypes.$gtoOrdType,
        CLasH.VHDL.VHDLTypes.$gtoOrdType],
       [CLasH.VHDL.VHDLTypes.$gfromHType,
        CLasH.VHDL.VHDLTypes.$gfromHType,
        CLasH.VHDL.VHDLTypes.$gfromHType],
       [CLasH.VHDL.VHDLTypes.$gtoHType, CLasH.VHDL.VHDLTypes.$gtoHType,
        CLasH.VHDL.VHDLTypes.$gtoHType],
       [CLasH.VHDL.VHDLTypes.$gfromVHDLState,
        CLasH.VHDL.VHDLTypes.$gfromVHDLState],
       [CLasH.VHDL.VHDLTypes.$gtoVHDLState,
        CLasH.VHDL.VHDLTypes.$gtoVHDLState]]
*** Offending Program ***

.. Many, Many lines of Core output ..

Note that when I compile without -XGenerics (but with -dcore-lint) I do not get any error.

I assume it has something to do with the following two lines in my sourcecode:

$( Data.Accessor.Template.deriveAccessors ''TypeState )
$( Data.Accessor.Template.deriveAccessors ''VHDLState )

As there are no errors when I remove those two TH splices (Sadly so, I need those accessors)

The implementation of Data.Accessor.Template.deriveAccessors can be found here (it's patched to work with version 2.4 of the template-haskell library): http://github.com/christiaanb/data-accessor/blob/988137e3cb152ff0c66ec97919069d765b3669c6/template/src/Data/Accessor/Template.hs

Maybe it's related to: #2456

For me it's not such a big problem as I will just compile that file with the NoGenerics Language pragma. But I would still like to know what might be causing this bug.

Change History (2)

comment:1 Changed 6 years ago by simonpj

  • difficulty set to Unknown
  • Owner set to simonpj

Ah I see what is going on. Fixing.

S

comment:2 Changed 6 years ago by simonpj

  • Resolution set to fixed
  • Status changed from new to closed
  • Test Case set to typecheck/should_compile/T3391

Good stuff. Fixed by

Thu Jul 23 16:58:03 BST 2009  [email protected]
  * Fix Trac #3391: make generic to/from bindings only for newly-declared types
  
  Before this patch we were bogusly making to/from bindings for all data types
  in the TcGblEnv.  But that is wrong when we have multiple "chunks" of 
  bindings in Template Haskell.  We should start from the declarations 
  themselves.  Easy.
  

    M ./compiler/typecheck/TcDeriv.lhs -7 +7

Thanks for the report

Simon

Note: See TracTickets for help on using tickets.