www.digitalmars.com         C & C++   DMDScript  

D - BUG: Internal error: ..\ztc\out.c 1127

reply "davepermen" <davepermen hotmail.com> writes:
playing with templates and aliases, i got
Feb 02 2004
parent reply "davepermen" <davepermen hotmail.com> writes:
damn:D wrong key..

well... playing with templates and aliased, i got

Internal error: ..\ztc\out.c 1127

in this code:

import std.c.stdio;

template max(T) {
 T max(T a,T b) {
  return a > b ? a : b;
 }
}

template Max(alias A,alias B) {
 typeof(A) Max() {
  return 0; max!(typeof(A))(A,B);
 }
}

int main(char[][] args) {
 int a = 5;
 int b = 10;
 printf("Max(%i,%i) = %i" \n,a,b,Max!(a,b)); //max!(int)(5,10));
 return getch();
}


i'd prefer to have a bether error message:D

btw, code can be reduced by much..
Feb 02 2004
parent reply "davepermen" <davepermen hotmail.com> writes:
like this:

template Foo(alias A) {
 void Foo() {
 }
}

int main(char[][] args) {
 int a = 5;
 Foo!(a);
 return getch();
}


"davepermen" <davepermen hotmail.com> schrieb im Newsbeitrag
news:bvl2qg$2in$1 digitaldaemon.com...
 damn:D wrong key..

 well... playing with templates and aliased, i got

 Internal error: ..\ztc\out.c 1127

 in this code:

 import std.c.stdio;

 template max(T) {
  T max(T a,T b) {
   return a > b ? a : b;
  }
 }

 template Max(alias A,alias B) {
  typeof(A) Max() {
   return 0; max!(typeof(A))(A,B);
  }
 }

 int main(char[][] args) {
  int a = 5;
  int b = 10;
  printf("Max(%i,%i) = %i" \n,a,b,Max!(a,b)); //max!(int)(5,10));
  return getch();
 }


 i'd prefer to have a bether error message:D

 btw, code can be reduced by much..
Feb 02 2004
next sibling parent "C" <dont respond.com> writes:
Thats cool , wish we had a tutorial on D's templates <nudge,nudge> (
Foo!(nudge,nudge ) ? )

C
"davepermen" <davepermen hotmail.com> wrote in message
news:bvl2sj$2op$1 digitaldaemon.com...
 like this:

 template Foo(alias A) {
  void Foo() {
  }
 }

 int main(char[][] args) {
  int a = 5;
  Foo!(a);
  return getch();
 }


 "davepermen" <davepermen hotmail.com> schrieb im Newsbeitrag
 news:bvl2qg$2in$1 digitaldaemon.com...
 damn:D wrong key..

 well... playing with templates and aliased, i got

 Internal error: ..\ztc\out.c 1127

 in this code:

 import std.c.stdio;

 template max(T) {
  T max(T a,T b) {
   return a > b ? a : b;
  }
 }

 template Max(alias A,alias B) {
  typeof(A) Max() {
   return 0; max!(typeof(A))(A,B);
  }
 }

 int main(char[][] args) {
  int a = 5;
  int b = 10;
  printf("Max(%i,%i) = %i" \n,a,b,Max!(a,b)); //max!(int)(5,10));
  return getch();
 }


 i'd prefer to have a bether error message:D

 btw, code can be reduced by much..
Feb 02 2004
prev sibling parent reply "Walter" <walter digitalmars.com> writes:
"davepermen" <davepermen hotmail.com> wrote in message
news:bvl2sj$2op$1 digitaldaemon.com...
 like this:

 template Foo(alias A) {
  void Foo() {
  }
 }

 int main(char[][] args) {
  int a = 5;
  Foo!(a);
  return getch();
 }
Looks like the compiler is failing to catch the illegal reference to the local 'a'.
Feb 07 2004
parent "davepermen" <davepermen hotmail.com> writes:
exactly. (but it would be great if it would not be illegal:D)

"Walter" <walter digitalmars.com> schrieb im Newsbeitrag
news:c03aj7$h3j$3 digitaldaemon.com...
 "davepermen" <davepermen hotmail.com> wrote in message
 news:bvl2sj$2op$1 digitaldaemon.com...
 like this:

 template Foo(alias A) {
  void Foo() {
  }
 }

 int main(char[][] args) {
  int a = 5;
  Foo!(a);
  return getch();
 }
Looks like the compiler is failing to catch the illegal reference to the local 'a'.
Feb 07 2004