www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4136] New: disable semantics

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4136

           Summary:  disable semantics
           Product: D
           Version: unspecified
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



This is not yet a bug report, but it can become one.
This is D2 code:

class A {
    void foo() {};
}
class B : A {
    override  disable void foo() {}
}
class C : B {
    override void foo() {};
}
void main() {
    A b1 = new B;
    b1.foo();

    B c1 = new C;
    c1.foo(); // Error: function test.B.foo is not callable...
}


It compiles with dmd 2.043 with an error:
test.d(15): Error: function test.B.foo is not callable because it is annotated
with  disable

The b1 is an instance of class B, but the call to foo produces no error. While
c1 is an instance of C, but it generates an error.

I don't understand well the design of  disable, but to be useful and more
meaningful isn't it necessary/better to enforce it (at run-time) on the dynamic
type of an object?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 30 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4136


Michal Minich <michal.minich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |michal.minich gmail.com



PDT ---

 I don't understand well the design of  disable, but to be useful and more
 meaningful isn't it necessary/better to enforce it (at run-time) on the dynamic
 type of an object?
disable is exactly for static enforcement, so it can work on statically know type of variable (not dynamic instance type). Dynamic enforcement is available via "override void foo() { assert(false) };". So I think this bug is invalid. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 18 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4136


bearophile_hugs eml.cc changed:

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





  disable is exactly for static enforcement, so it can work on statically know
 type of variable (not dynamic instance type). Dynamic enforcement is available
 via "override void foo() { assert(false) };". So I think this bug is invalid.
Three years later I understand disable better, and indeed this is invalid. Hopefully other D programmers will not make the same mistake of mine. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 18 2013