digitalmars.D.bugs - [Issue 1241] New: ICE on template instance parameter
- d-bugmail puremagic.com (38/38) May 18 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1241
- d-bugmail puremagic.com (9/9) Jun 23 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1241
- d-bugmail puremagic.com (32/32) Jul 22 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1241
- =?ISO-8859-1?Q?Manuel_K=F6nig?= (52/96) Aug 01 2007 I just discovered a decent workaround. Instead of using templates with
http://d.puremagic.com/issues/show_bug.cgi?id=1241
           Summary: ICE on template instance parameter
           Product: D
           Version: 1.014
          Platform: PC
        OS/Version: All
            Status: NEW
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: manuelk89 gmx.net
The following template instance parameter crashes dmd when the parameter gets
accessed:
template List(L...)
{
        alias L get;
}
template Foo(alias A)
{
        int len1 = A.get.length; // access causes ICE
}
void main()
{
        alias Foo!(List!(1,2,3)) foo; // instance parameter is List!(1,2,3)
}
-------------------------------
compile session:
$ dmd main.d
dmd: expression.c:4729: virtual Expression* DotIdExp::semantic(Scope*):
Assertion `0' failed.
Aborted (core dumped)
---
PS: when this gets fixed there is a nice way to pass more than one Tuple to a
template by just passing several template instances that carry the tuples in
them (just as the List template above).
-- 
 May 18 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1241
onlystupidspamhere yahoo.se changed:
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE
*** This bug has been marked as a duplicate of 911 ***
-- 
 Jun 23 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1241
shro8822 vandals.uidaho.edu changed:
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |shro8822 vandals.uidaho.edu
I have also run into this one. I was trying to use the tuples+templates as
compile time trees
template Foo(A...)
{
  template Bar(B...)
  {
    alias A a;
    alias B b;
  }
}
alias Foo!(Foo!(1,2,3).Bar!(4,5,6)).Bar!(Foo!(7,8,9).Bar!(10,11,12)) tree;
foreach( a; tree.a)
{
  foreach(aa; a.a);
  foreach(ab; a.b);
}
foreach( b; tree.b)
{
  foreach(ba; b.a);
  foreach(bb; b.b);
}
Can we please get a fix on this one? It will drop a LOT of barriers to
elaborate template systems. I have a few really cool things that use it and
would like to put them in my talk without the disclaimer of "this would work
-- 
 Jul 22 2007
d-bugmail puremagic.com wrote:
 http://d.puremagic.com/issues/show_bug.cgi?id=1241
 
 
 shro8822 vandals.uidaho.edu changed:
 
            What    |Removed                     |Added
 ----------------------------------------------------------------------------
                  CC|                            |shro8822 vandals.uidaho.edu
 
 
 
 
 I have also run into this one. I was trying to use the tuples+templates as
 compile time trees
 
 template Foo(A...)
 {
   template Bar(B...)
   {
     alias A a;
     alias B b;
   }
 }
 
 alias Foo!(Foo!(1,2,3).Bar!(4,5,6)).Bar!(Foo!(7,8,9).Bar!(10,11,12)) tree;
 
 foreach( a; tree.a)
 {
   foreach(aa; a.a);
   foreach(ab; a.b);
 }
 foreach( b; tree.b)
 {
   foreach(ba; b.a);
   foreach(bb; b.b);
 }
 
 Can we please get a fix on this one? It will drop a LOT of barriers to
 elaborate template systems. I have a few really cool things that use it and
 would like to put them in my talk without the disclaimer of "this would work
 
 
I just discovered a decent workaround. Instead of using templates with 
tuple members, just use structs:
Use
struct Tuple(T...)
{
	alias T tp;
}
instead of
template Tuple(T...)
{
	alias T tp;
}
I tested this with dmd1.020 and rewrote your tree structure using this 
trick:
import std.stdio;
struct Foo(A...)
{
   struct Bar(B...)
   {
     alias A a;
     alias B b;
   }
}
alias Foo!(Foo!(1,2,3).Bar!(4,5,6)).Bar!(Foo!(7,8,9).Bar!(10,11,12)) tree;
void main()
{
	foreach( a; tree.a)
	{
	  foreach(aa; a.a) writefln(aa);
	  foreach(ab; a.b) writefln(ab);
	}
	foreach( b; tree.b)
	{
	  foreach(ba; b.a) writefln(ba);
	  foreach(bb; b.b) writefln(bb);
	}
}
This prints
1
2
3
4
5
6
7
8
9
10
11
12
for me. Happy coding!
 Aug 01 2007








 
  
  
 
 d-bugmail puremagic.com
 d-bugmail puremagic.com 