Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
November 05, 2010 [Issue 5171] New: @disable doesn't work on opEquals functions | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=5171 Summary: @disable doesn't work on opEquals functions Product: D Version: D2 Platform: Other URL: http://www.digitalmars.com/d/2.0/attribute.html#disabl e OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: Jesse.K.Phillips+D@gmail.com CC: Jesse.K.Phillips+D@gmail.com --- Comment #0 from Jesse Phillips <Jesse.K.Phillips+D@gmail.com> 2010-11-05 10:15:28 PDT --- When overriding a function of a base class @disable does not cause compile time errors when called. class A { @disable override equals_t opEquals(Object other) { return false; } } void main() { auto a = new A(); auto b = new A(); if(a == b) assert(0); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 05, 2010 [Issue 5171] @disable doesn't work on opEquals functions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesse Phillips | http://d.puremagic.com/issues/show_bug.cgi?id=5171 Steven Schveighoffer <schveiguy@yahoo.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |schveiguy@yahoo.com Resolution| |INVALID --- Comment #1 from Steven Schveighoffer <schveiguy@yahoo.com> 2010-11-05 11:00:33 PDT --- This isn't actually possible. What I would suggest is the compiler failing to compile your class instead, because you can't disable a base function. If for example, you have a function like this: bool foo(Object o1, Object o2) {...} Then would it be safe to assume that you could pass both a and b to foo? If so, then isn't it possible for foo to call o1 == o2? And how could the compiler possibly statically disable this? I'm going to mark it as invalid, and if you think you'd rather have the behavior where @disable doesn't compile on overridden functions, then you can reopen with that description. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 05, 2010 [Issue 5171] @disable doesn't work on opEquals functions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesse Phillips | http://d.puremagic.com/issues/show_bug.cgi?id=5171 bearophile_hugs@eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs@eml.cc --- Comment #2 from bearophile_hugs@eml.cc 2010-11-05 11:15:45 PDT --- (In reply to comment #1) > This isn't actually possible. What I would suggest is the compiler failing to compile your class instead, because you can't disable a base function. I agree. Where possible a good compiler has to statically disallow impossible code :-) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 05, 2010 [Issue 5171] @disable doesn't work on opEquals functions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesse Phillips | http://d.puremagic.com/issues/show_bug.cgi?id=5171 --- Comment #3 from bearophile_hugs@eml.cc 2010-11-05 11:17:54 PDT --- Added a note to bug 3934 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 09, 2010 [Issue 5171] Prevent compiling of class when @disable is used on an overriding function | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesse Phillips | http://d.puremagic.com/issues/show_bug.cgi?id=5171 Jesse Phillips <Jesse.K.Phillips+D@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|INVALID | Summary|@disable doesn't work on |Prevent compiling of class |opEquals functions |when @disable is used on an | |overriding function Severity|normal |enhancement --- Comment #4 from Jesse Phillips <Jesse.K.Phillips+D@gmail.com> 2010-11-09 11:10:36 PST --- class A { void hello() { } } class B : A { @disable override void hello() { } } void main() { auto a = new A(); A b = new B(); b.hello(); } The compiler should not compile the class saying something to the effect of: Can not disable method hello in base class A from B. Or another suggestion "Cannot @disable overriding function hello in B" Note that I think the code below should still compile: class A { @disable void hello() { } } class B : A { override void hello() { } } void main() { auto a = new A(); B b = new B(); b.hello(); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation