Bug 4528 – Better error message for private abstract method
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-07-28T15:20:00Z
Last change time
2013-03-27T05:16:23Z
Keywords
diagnostic, pull
Assigned to
andrej.mitrovich
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2010-07-28T15:20:52Z
With this wrong program:
abstract class Foo {
final abstract void bar();
}
void main() {}
dmd 2.047 generates the error message:
test.d(2): Error: function test.Foo.bar cannot be both final and abstract
With this other wrong program:
abstract class Foo {
private abstract void bar();
}
void main() {}
dmd generates the error message:
prog.d(2): Error: function test.Foo.bar non-virtual functions cannot be abstract
But I think this second error message can be improved, because at first look bar() looks virtual:
test.d(2): Error: member function test.Foo.bar() cannot be both private and abstract.
Or (inspired by C# compiler):
test.d(2): Error: member function test.Foo.bar(): abstract functions cannot be private.
Or (inspired by Java compiler):
test.d(2): Error: method test.Foo.bar(): illegal combination of modifiers: abstract and private.
Comment #1 by andrej.mitrovich — 2012-12-27T16:59:52Z