Bug 13224 – Error: first argument is not a symbol

Status
RESOLVED
Resolution
WONTFIX
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-07-29T14:39:00Z
Last change time
2014-07-31T11:46:25Z
Assigned to
nobody
Creator
dragoscarp

Comments

Comment #0 by dragoscarp — 2014-07-29T14:39:45Z
Following code minimized from an application unitest using dunit doesn't compile with 2.066.0-b6 (2.065 was ok): FooTest.d(30): Error: first argument is not a symbol FooTest.d(36): Error: template instance FooTest.FooTest.UnitTest!()._annotations!(FooTest, Ignore, "Node", "toString", "toHash", "opCmp", "opEquals", "Monitor", "factory") error instantiating FooTest.d(32): instantiated from here: _annotations!(FooTest, Ignore, "_annotations", "Node", "toString", "toHash", "opCmp", "opEquals", "Monitor", "factory") FooTest.d(16): instantiated from here: _annotations!(FooTest, Ignore, "__ctor", "_annotations", "Node", "toString", "toHash", "opCmp", "opEquals", "Monitor", "factory") =================================== import std.typetuple; class Document { alias NodeImpl* Node; struct NodeImpl { } } template UnitTest() { this() { alias TypeTuple!(__traits(allMembers, typeof(this))) allMembers; _annotations!(typeof(this), Ignore, allMembers).dup; } template _annotations(T, attribute, names...) { static if (names.length == 0) { immutable(string[]) _annotations = []; } else { static if (__traits(compiles, mixin("(new " ~ T.stringof ~ "())." ~ names[0] ~ "()"))) { alias TypeTuple!(__traits(getMember, T, names[0])) member; TypeTuple!(__traits(getAttributes, member)) attributes; immutable(string[]) _annotations = _annotations!(T, attribute, names[1 .. $]); } else { immutable(string[]) _annotations = _annotations!(T, attribute, names[1 .. $]); } } } } struct Ignore { } class FooTest { mixin UnitTest; alias Node = Document.Node; } ====================================================================
Comment #1 by k.hara.pg — 2014-07-29T15:23:21Z
In 2.066, uniform constructor syntax T() is supported for all scalar type T. auto n = int(); auto x = float(3.14); alias P = void*; auto p = P(&n); By the feature, the line static if (__traits(compiles, mixin("(new " ~ T.stringof ~ "())." ~ names[0] ~ "()"))) is changed to be evaluated to true when names[0] == "Node". (new FooTest()).Node() == Node() (Node == Document.Node == NodeImpl*)
Comment #2 by bugzilla — 2014-07-31T02:45:01Z
Evidently this new feature is breaking code. Sigh.
Comment #3 by dragoscarp — 2014-07-31T11:46:25Z
Thank you for your comments. Set it to RESOLVED/WONTFIX: For filtering just the function members of a Unittest class, dunit uses now std.traits.isSomeFunction. https://github.com/linkrope/dunit/commit/d711ec64783ed3224f5869414aaae94ba8cfdac5#diff-be2abaac367f0a0237d4cc7d9fd57a3aR691