[Issue 10416] Wrong error messages for inherited @safe class method

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jun 19 11:25:59 PDT 2013


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



--- Comment #1 from Kenji Hara <k.hara.pg at gmail.com> 2013-06-19 11:25:57 PDT ---
(In reply to comment #0)
> import std.stdio: writeln;
> abstract class Foo {
>     void spam() @safe;
> }
> class Bar : Foo {
>     override void spam() {
>         writeln;
>     }
> }
> void main() {}
> 
> 
> 
> DMD 2.063.2 gives the error message:
> 
> temp.d(7): Error: safe function 'bug2.Bar.spam' cannot call system function
> 'std.stdio.writeln!().writeln'
> 
> Even assuming that it's correct to label writeln() as a system function,
> Bar.foo is not labeled @safe. So I think the correct error message is similar
> to (note the use of system and @safe words below):
> 
> 
> test.d(6): Error: system function bug2.Bar.spam does not override any function,
> did you mean to override @safe function 'bug2.Foo.spam'?


This is correct error message. Bar.spam is implicitly inherits @safe attriubte
from Foo.spam.

http://dlang.org/function#function-inheritance

Then Bar.spam is implicitly annotated with @safe, and system function call will
become invalid.

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