www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10416] New: Wrong error messages for inherited safe class method

reply d-bugmail puremagic.com writes:
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



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: -------
Jun 19 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10416





 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: -------
Jun 19 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10416


bearophile_hugs eml.cc changed:

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



Thank you Kenji, my mistake.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 19 2013