http://d.puremagic.com/issues/show_bug.cgi?id=918



--- Comment #4 from Witold Baryluk <bary...@smp.if.uj.edu.pl> 2009-11-18 
21:25:29 PST ---
I recently retested this code in DMD 2.032:


a918.d:
-----
import std.stdio;

typedef int num = 42;

version (A) {
    void pow(alias b)() {     writefln("alias %d", b); }
    void pow(num b)() {    writefln("num %d", b); }
    void pow(int b)() {    writefln("int %d", b); }
} else version (B) {
    void pow(num b)() {    writefln("num %d", b); }
    void pow(alias b)() {     writefln("alias %d", b); }
    void pow(int b)() {    writefln("int %d", b); }
} else version (C) {
    void pow(num b)() {    writefln("num %d", b); }
    void pow(alias b)() {     writefln("alias %d", b); }
} else {
    static assert(false, "Provide version");
}


void main() {
    num wyk = 22;
writeln("calling num wyk=22?");
    pow!(wyk)();

writeln("calling int=4?");
    pow!(4)();

    uint x = 333;
writeln("calling alias=x=333?");
    pow!(x)();
}
-----

It looks it behaves much better than original bug report:

------
bary...@sredniczarny:/tmp$ dmd2 -version=A -w a918.d ; ./a918 
calling num wyk=22?
num -1077524476
calling int=4?
int 4
calling alias=x=333?
alias 333
bary...@sredniczarny:/tmp$ dmd2 -version=B -w a918.d ; ./a918 
calling num wyk=22?
num -1081977116
calling int=4?
int 4
calling alias=x=333?
alias 333
bary...@sredniczarny:/tmp$ dmd2 -version=C -w a918.d ; ./a918 
calling num wyk=22?
num -1076793804
calling int=4?
alias 4
calling alias=x=333?
alias 333
bary...@sredniczarny:/tmp$ 
-----

We have the same behaviour regardles of version. In version C int properly uses
"alias" template. Order of templates doesn't metter. Removing or leaving
"version" blocks, doesn't change behaviour.


But here we also see regression. num is not passed correctly. Even after
removing "version" blocks, and leaving only "B" part. It also doesn't print any
"0" or "42", or desired "22", but some random negative number.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to