[Issue 9630] DMD git: can't access array field properties from static method

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Mar 1 22:27:28 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9630



--- Comment #13 from Kenji Hara <k.hara.pg at gmail.com> 2013-03-01 22:27:27 PST ---
(In reply to comment #10)
> > auto x = typeof(arr.map!(x => x*2).filter!(x > 4).array[0]).max;
> 
> Well, I don't know about how this fits with backwards compatibility and such,
> but the above line looks wrong to me as well, since it's passing a non-existent
> variable (arr) to a function (map). This is as much "runtime evaluated" as
> taking its index.

Using non-static variable directly under the typeof should be allowed.
If you use 'typeof', you means "I want to just get the type of specified
expression, and does not consider whether the expression can be evaluate in
runtime." In this point, D accepts it explicitly.

Moreover, that is necessary for the use at out of function scope.

struct S {
    int field1;
    typeof(field1) field2;  // field1 access has no "valid this", but allowed
    static void foo() {
        typeof(field1) x;   // field1 access has no "valid this", but allowed
    }
}

This is also consistent behavior.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list