valderman / haste-compiler

A GHC-based Haskell to JavaScript compiler
http://haste-lang.org
BSD 3-Clause "New" or "Revised" License
1.45k stars 115 forks source link

Name conflict in buildStgName #411

Open phi16 opened 6 years ago

phi16 commented 6 years ago

In https://github.com/valderman/haste-compiler/blob/ab0f6c1bbb93e9919205c804817e99e1455aa325/src/Haste/AST/PP.hs#L109 (buildStgName function) , I suspected that the operator (*) and (-) will be mangled to same symbol...

Actually in my case, instance Num (Var String) generates following codes (with --debug option) :

_6P/* $fNumVar_$c* */ = function(_6Q/* s4S9 */, _6R/* s4Sa */){
  return new T1(1,new T2(1,_1Q/* Main.$c+5 */,new T2(1,_6Q/* s4S9 */,new T2(1,_6O/* Main.$fNumVar5 */,new T2(1,_6R/* s4Sa */,_G/* Main.lvl5 */)))));
},
...,
_6W/* $fNumVar_$c- */ = function(_6X/* s4Sl */, _6Y/* s4Sm */){
  return new F(function(){return A3(_6S/* GHC.Num.+ */,_6Z/* Main.$fNumVar */, _6X/* s4Sl */, new T(function(){
    return B(A2(_6U/* GHC.Num.negate */,_6Z/* Main.$fNumVar */, _6Y/* s4Sm */));
  }));});
},

but these cause name conflict on compiling with an option --preserve-names

$hs$Main$$fNumVar_$c_ = function($hs$Main$s4S9, $hs$Main$s4Sa){
  return new T1(1,new T2(1,$hs$Main$$c_5,new T2(1,$hs$Main$s4S9,new T2(1,$hs$Main$$fNumVar5,new T2(1,$hs$Main$s4Sa,$hs$Main$lvl5)))));
},
...,
$hs$Main$$fNumVar_$c_ = function($hs$Main$s4Sl, $hs$Main$s4Sm){
  return new F(function(){return A3($hs$GHC_Num$_,$hs$Main$$fNumVar, $hs$Main$s4Sl, new T(function(){
    return B(A2($hs$GHC_Num$negate,$hs$Main$$fNumVar, $hs$Main$s4Sm));
  }));});
},

I want to use --preserve-names to profile my program :D I'm using x86_64-windows-haste-0.6.0.0-ghc-7.10.2.

Thanks.

phi16 commented 6 years ago

Note : it seems that >>= and <*> are mangled to $hs$GHC_Base$___ and causing a conflict too.