Bug 2219 – typeof requiring extra parentheses

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2008-07-12T00:16:39Z
Last change time
2019-08-20T11:45:59Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
Bill Baxter

Comments

Comment #0 by wbaxter — 2008-07-12T00:16:39Z
Tested with D1.033, actually. ------------------------ struct Thing(Scalar) { Scalar x,y,z; } //alias typeof(Thing!(float).x) SC; // -- This used to work, but I understand it has been deprecated. // It's going to make such things look uglier, but OK. /+ bug.d(30): Error: this is not in a struct or class scope bug.d(30): Error: 'this' is only allowed in non-static member functions, not main bug.d(30): Error: this for x needs to be type Thing not type int +/ //alias typeof(Thing!(float).init.x) SC2; /+ bug.d(32): Error: undefined identifier struct Thing.init bug.d(32): Error: no property 'x' for type 'void' +/ //alias typeof((Thing!(float).init).x) SC3; /+ bug.d(37): Error: Thing!(float).init is used as a type bug.d(37): Error: no property 'x' for type 'void' +/ alias typeof((Thing!(float)).init.x) SCy; // this works --------------------------- The last example works, but it requires parentheses in a place where I don't think techically they should have any meaning. Defining an intermediate alias also works: alias typeof(Thing!(float)) ThingFloat; alias typeof(ThingFloat.init.x) SCy; // ok too
Comment #1 by wbaxter — 2008-07-12T00:17:17Z
Comment #2 by wbaxter — 2008-07-14T15:40:17Z
Bumped to 1.033 because that's where it was actually observed. (1.033 label was not available when I filed originally)
Comment #3 by razvan.nitu1305 — 2019-08-20T11:45:59Z
All the examples filed in the original bug report work in D2. Closing...