Thread overview
[Issue 2219] New: typeof requiring extra parentheses
Jul 12, 2008
d-bugmail
Jul 12, 2008
d-bugmail
Jul 14, 2008
d-bugmail
July 12, 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@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
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


-- 

July 12, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2219





------- Comment #1 from wbaxter@gmail.com  2008-07-12 00:17 -------
May be related to: http://d.puremagic.com/issues/show_bug.cgi?id=2154


-- 

July 14, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2219


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)


--