Bug 7613 – __traits(getMember) on inner unittest: Assertion failure: 'type' on line 6695 in file 'expression.c'

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-02-29T11:20:00Z
Last change time
2013-01-08T12:57:47Z
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2012-02-29T11:20:53Z
I was attempting to use is(typeof) or __traits(compiles) to tell if a field of a struct can be converted to a string. However when __traits(getMember) tries to return a unittest this causes an ICE: import std.conv; struct Foo { int x; unittest { } } void test(T)(T t) { foreach (member; __traits(allMembers, T)) { enum testString = "static if( is(typeof( to!string(__traits(getMember, t, " ~ `"` ~ member ~ `"` ~ "))) )) { };"; mixin(testString); } } void main() { Foo foo; test(foo); __traits(getMember, foo, "__unittest1"); } Assertion failure: 'type' on line 6695 in file 'expression.c' The minimal test-case is the last line: __traits(getMember, foo, "__unittest1"); If it was simply an error it could be caught with is(typeof), but it's an ICE.
Comment #1 by andrej.mitrovich — 2013-01-08T12:57:47Z
It seems allMembers doesn't iterate through unittests anymore, not even getMember can fetch the unittest (compiling with -unittest).