| Thread overview | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
February 02, 2004 BUG: Internal error: ..\ztc\out.c 1127 | ||||
|---|---|---|---|---|
| ||||
playing with templates and aliases, i got | ||||
February 02, 2004 Re: Internal error: ..\ztc\out.c 1127 | ||||
|---|---|---|---|---|
| ||||
Posted in reply to davepermen | 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..
| |||
February 02, 2004 Re: Internal error: ..\ztc\out.c 1127 | ||||
|---|---|---|---|---|
| ||||
Posted in reply to davepermen | 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..
>
>
| |||
February 02, 2004 Re: Internal error: ..\ztc\out.c 1127 | ||||
|---|---|---|---|---|
| ||||
Posted in reply to davepermen | 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.. > > > > > > | |||
February 07, 2004 Re: Internal error: ..\ztc\out.c 1127 | ||||
|---|---|---|---|---|
| ||||
Posted in reply to davepermen | "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'. | |||
February 07, 2004 Re: Internal error: ..\ztc\out.c 1127 | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Walter | 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'. > > | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply