[Issue 11258] Static field access problem

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Oct 14 07:26:09 PDT 2013


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


Kenji Hara <k.hara.pg at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


--- Comment #2 from Kenji Hara <k.hara.pg at gmail.com> 2013-10-14 07:26:07 PDT ---
(In reply to comment #1)
> (In reply to comment #0)
> > In dmd 2.063 this used to work.
> 
> This is a regression from 2.062, and same error occurs with 2.063.

Sorry, this is NOT a regression. Current behavior is intended.

In class/struct DeclDefs scope, directly using function literal is not allowed.

struct Bar {
    int var;
    auto dg = { return var; };
    // Error: function literals cannot be class members
}

Against that, __traits(compiles) has *no* special handling. Therefore,

struct Bar {
    int var;
    static assert(__traits(compiles, { return var; }));
    // catch "cannot be class members" error, then returns false
}

The static assert correctly fails. Therefor current behavior is intended.

On the other hand, this error check is stopped inside typeof operator. It's
also an intended behavior.

So, in this case, please use is(typeof({ ... })) instead.

====

Note: The old bug, existed in 2.062 and earlier, was fixed in here:
https://github.com/D-Programming-Language/dmd/commit/0679c4c31ba78853873933324c69cd90e7714d15#diff-ffa5582af7d723c487d4a11ac6743b85R84

-- 
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