[Issue 9100] Weird behavior on template instance argument
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Nov 30 19:36:06 PST 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9100
--- Comment #2 from Kenji Hara <k.hara.pg at gmail.com> 2012-11-30 19:36:04 PST ---
As a related note, this program runs successfully with no error in current
compiler.
It looks weird, but is expected from the view of language consistency.
void main(){ (new C(1)).test(); }
template Id(alias A) { alias Id = A; }
class C
{
int n;
this(int x){ n = x; }
int fun(){ return n; }
void test()
{
auto c = new C(2);
assert(c.fun() == 2);
alias f = Id!(c.fun);
assert(f() == 1); // calls this.fun, not c.fun
}
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list