Thread overview | |||||
---|---|---|---|---|---|
|
June 19, 2013 [Issue 10416] New: Wrong error messages for inherited @safe class method | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=10416 Summary: Wrong error messages for inherited @safe class method Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Keywords: diagnostic Severity: minor Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: bearophile_hugs@eml.cc --- Comment #0 from bearophile_hugs@eml.cc 2013-06-19 10:46:41 PDT --- 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'? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 19, 2013 [Issue 10416] Wrong error messages for inherited @safe class method | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=10416 --- Comment #1 from Kenji Hara <k.hara.pg@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: ------- |
June 19, 2013 [Issue 10416] Wrong error messages for inherited @safe class method | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=10416 bearophile_hugs@eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID --- Comment #2 from bearophile_hugs@eml.cc 2013-06-19 12:18:50 PDT --- Thank you Kenji, my mistake. -- 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