[Issue 2454] typeof(object) is incorrectly evaluated
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Nov 14 17:42:52 PST 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2454
2korden at gmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|tupleof(member) is |typeof(object) is
|incorrectly evaluated inside|incorrectly evaluated
|foreach over members-tuple |
------- Comment #3 from 2korden at gmail.com 2008-11-14 19:42 -------
I believe this is relevant:
import std.stdio;
void foo(T)(T t)
{
assert(is(typeof(t) == T));
writeln(T.stringof);
writefln(typeof(t).stringof);
}
struct A
{
int i;
void test()
{
foreach (m; this.tupleof) {
foo(m); // line 17
}
}
}
void main()
{
foo(new A());
}
Expected output:
A*
A*
Actual output:
A*
int
Looks like result of typeof(t) is evaluated just once at compile time and then
reused at every template instantiation. Commenting line 17 hides the issue.
--
More information about the Digitalmars-d-bugs
mailing list