[Issue 5110] New: Excess attribute propagation of structs and classes

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Oct 24 02:03:59 PDT 2010


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

           Summary: Excess attribute propagation of structs and classes
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: spec
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: rsinfu at gmail.com


--- Comment #0 from Shin Fujishiro <rsinfu at gmail.com> 2010-10-24 02:02:08 PDT ---
The override attribute is unnecessarily propagated to a nested class
declaration and causes errors:
--------------------
class C
{
 override:
    string toString() { return ""; }

    class Nested
    {                       // (7)
        void gun() {}       // (8)
    }
}
--------------------
test.d(8): Error: function test.C.Nested.gun does not override any function
test.d(7): Error: variable test.C.Nested.this override cannot be applied to
variable
--------------------

Another case.  The const attribute is propagated to a static member:
--------------------
const struct S
{
    static int value;
}
static assert(is(typeof(S.value) == int));  // (5)
--------------------
test.d(5): Error: static assert  (is(const(int) == int)) is false
--------------------

Though the spec allows this behavior, I think it's more natural if the static
member variable S.value is typed as mutable int.

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