www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2219] New: typeof requiring extra parentheses

reply d-bugmail puremagic.com writes:

           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 digitalmars.com
        ReportedBy: wbaxter 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
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

Jul 11 2008
next sibling parent d-bugmail puremagic.com writes:

------- Comment #1 from wbaxter gmail.com  2008-07-12 00:17 -------
May be related to:

Jul 11 2008
prev sibling parent d-bugmail puremagic.com writes:

wbaxter gmail.com changed:

           What    |Removed                     |Added
            Version|1.032                       |1.033

------- Comment #2 from wbaxter gmail.com  2008-07-14 15:40 -------
Bumped to 1.033 because that's where it was actually observed.
(1.033 label was not available when I filed originally)

Jul 14 2008