[Issue 2219] New: typeof requiring extra parentheses
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Jul 11 22:16:40 PDT 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2219
Summary: typeof requiring extra parentheses
Product: D
Version: 1.032
Platform: PC
OS/Version: Windows
Status: NEW
Keywords: rejects-valid
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: wbaxter at gmail.com
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
--
More information about the Digitalmars-d-bugs
mailing list