[nem-bug] [Nemerle 0000830]: ICE when using Alias (only for some methods)

feedback at nemerle.org feedback at nemerle.org
Thu Feb 15 21:50:10 CET 2007


A NOTE has been added to this issue.
======================================================================
<http://nemerle.org/bugs/view.php?id=830> 
======================================================================
Reported By:                d
Assigned To:                
======================================================================
Project:                    Nemerle
Issue ID:                   830
Category:                   Compiler
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
======================================================================
Date Submitted:             01-20-2007 20:25 CET
Last Modified:              02-15-2007 21:50 CET
======================================================================
Summary:                    ICE when using Alias (only for some methods)
Description: 
I tried adding aliases in rlist.n and it works fine for all methods but
FoldLeft, FoldRight and Map.
For example if this line:

  [Nemerle.Alias (FoldLeft (acc, f))]

is added above:

  public static FoldLeft ['b] (xs : RList ['a], acc : 'b, f : 'a * 'b ->
'b) : 'b

in rlist.n and the corresponding non-static method below is commented out
like this:

  //    public FoldLeft ['b] (acc : 'b, f : 'a * 'b -> 'b) : 'b {
  //      FoldLeft (this, acc, f)
  //    }

I get:

h82-143-167-72-static:~/src/nemerle/lib d$ make
cd ../ncc ; make lib
make STAGE=stage1 OUTF_STAGE=stage1. out.stage1/Nemerle.stage1.dll
COMPILE [stage1] Nemerle.dll
_________...................................................
error: internal compiler error: got some unknown exception of type
System.ApplicationException: Can't define method 'FoldLeft' (attrs:
Public, HideBySig) in type 'Nemerle.Collections.RList`1'.
Error: assertion ``gtype != null'' failed in file typing/StaticTyVar.n,
line 123:
'b.1487
  at Nemerle.Compiler.MethodBuilder.CreateMethodBuilder
(System.Reflection.Emit.TypeBuilder tb) [0x00000] 
  at Nemerle.Compiler.MethodBuilder.CreateEmitBuilder
(System.Reflection.Emit.TypeBuilder tb) [0x00000] 
  at Nemerle.Compiler.TypeBuilder.CreateEmitDeclarations () [0x00000] 
  at Nemerle.Compiler.TypesManager+_N_emit_decls_28794.apply_void
(Nemerle.Compiler.TypeBuilder _N_28793) [0x00000]   at
Nemerle.Compiler.TypesManager+_N__N_l29368_29386.apply_void
(Nemerle.Compiler.TypeBuilder _N_29385) [0x00000] 
  at Nemerle.Compiler.TypesManager+_N_maybe_f_29339.apply_void
(Nemerle.Compiler.TypeBuilder _N_29338) [0x00000] 
  at Nemerle.Collections.List.Iter[TypeBuilder] (Nemerle.Core.list`1 l,
Nemerle.Builtins.FunctionVoid`1 f) [0x00000] 
  at Nemerle.Core.list`1[Nemerle.Compiler.TypeBuilder].Iter
(Nemerle.Builtins.FunctionVoid`1 ) [0x00000] 
  at Nemerle.Compiler.TypesManager.Iter (Nemerle.Core.list`1 builders,
Nemerle.Builtins.FunctionVoid`1 f) [0x00000]   at
Nemerle.Compiler.TypesManager.IterConditionally
(Nemerle.Builtins.FunctionVoid`1 f, Nemerle.Builtins.Function`2 cond)
[0x00000] 
  at Nemerle.Compiler.TypesManager.compile_all_tyinfos (Boolean aux_phase)
[0x00000] 
  at Nemerle.Compiler.TypesManager+_N__N_l28375_28466.apply_void ()
[0x00000] 
  at Nemerle.Compiler.Solver.Enqueue (Nemerle.Builtins.FunctionVoid
action) [0x00000] 
  at Nemerle.Compiler.TypesManager.EmitDecls () [0x00000] 
  at Nemerle.Compiler.ManagerClass.Run () [0x00000] 
  at Nemerle.CommandlineCompiler.MainClass.main_with_catching () [0x00000]

======================================================================

----------------------------------------------------------------------
 nazgul - 01-21-07 20:36 
----------------------------------------------------------------------
It's no suprise, since Alias macro hasn't got a single sign of handling
generic parameters ;)

----------------------------------------------------------------------
 d - 01-21-07 22:12 
----------------------------------------------------------------------
Heheh. I thought it would work with generic parameters :-o
How would it have to be modified then (the macro) ? If you ever have a
second to tell me I'm always on freenode (and the mailing list, although I
have 400 unread messages there ;]). Thanks and sorry for the pointless bug
report.

----------------------------------------------------------------------
 nazgul - 01-21-07 22:19 
----------------------------------------------------------------------
I remember I had the same question with ProxyPublicMembers... and I still
don't know the answer. I think Michal should point us to the proper API,
what we need is:

1. take IMethod's generic parameters
2. create their duplicated (new parameters, which will be used by new
method)
3. traverse the types, substituting occurences of original parameters with
our mapped duplicated

Of course only the last step is hard - I wouldn't like to do it manually,
I think that maybe "Subst" class could be used there. Some small tutorial
on using it would be helpful, Michal?

----------------------------------------------------------------------
 malekith - 01-25-07 12:05 
----------------------------------------------------------------------
You need to

def (subst, new_tyvars) = StaticTyVar.CopyList(imethod_tyvars);
def new_ret_type = subst.MonoApply (imethod_ret_type);
...

----------------------------------------------------------------------
 nazgul - 01-25-07 21:45 
----------------------------------------------------------------------
Looks like it won't be easy to inject list[StaticTyVar] into existing
MethodBuilder... but I guess should be possible - Typedtree.Fun_header 
should provide method ExchangeTyparms (list[StaticTyVar]) and rebuild its
tenv basing on parent type and new typarms... It might cause problems if
existing StaticTyVars were already used during binding of types in
signature, but this should not be a case in our scenario.

----------------------------------------------------------------------
 nazgul - 02-15-07 21:50 
----------------------------------------------------------------------
You might try 
meth.GetHeader ().CreateAliasMethod 
method or similar thing as it does.

See

http://nemerle.org/svn/nemerle/trunk/macros/DesignPatterns.n
http://nemerle.org/svn/nemerle/trunk/ncc/typing/TypedTree.n

Issue History
Date Modified  Username       Field                    Change              
======================================================================
01-20-07 20:25 d              New Issue                                    
01-21-07 20:36 nazgul         Note Added: 0001623                          
01-21-07 22:12 d              Note Added: 0001627                          
01-21-07 22:19 nazgul         Note Added: 0001628                          
01-25-07 12:05 malekith       Note Added: 0001634                          
01-25-07 21:45 nazgul         Note Added: 0001639                          
02-15-07 21:50 nazgul         Note Added: 0001733                          
======================================================================




More information about the bugs mailing list