[Issue 12939] New: More uniform error messages for not nothrow and not @safe functions
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Tue Jun 17 10:26:41 PDT 2014
    
    
  
https://issues.dlang.org/show_bug.cgi?id=12939
          Issue ID: 12939
           Summary: More uniform error messages for not nothrow and not
                    @safe functions
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: diagnostic
          Severity: minor
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: bearophile_hugs at eml.cc
void main() pure nothrow @safe @nogc {
    import std.stdio;
    writeln(1);
}
DMD 2.066alpha gives:
test.d(3,12): Error: pure function 'D main' cannot call impure function
'std.stdio.writeln!(int).writeln'
test.d(3,12): Error: safe function 'D main' cannot call system function
'std.stdio.writeln!(int).writeln'
test.d(3,12): Error: @nogc function 'D main' cannot call non- at nogc function
'std.stdio.writeln!(int).writeln'
test.d(3,12): Error: 'std.stdio.writeln!(int).writeln' is not nothrow
test.d(1,6): Error: function 'D main' is nothrow yet may throw
I suggest error messages like (note the different single error message for
nothrow, and the use of @safe/@system instead of safe/system):
test.d(3,12): Error: pure function 'D main' cannot call impure function
'std.stdio.writeln!(int).writeln'
test.d(3,12): Error: nothrow function 'D main' cannot call non-nothrow function
'std.stdio.writeln!(int).writeln'
test.d(3,12): Error: @safe function 'D main' cannot call @system function
'std.stdio.writeln!(int).writeln'
test.d(3,12): Error: @nogc function 'D main' cannot call non- at nogc function
'std.stdio.writeln!(int).writeln'
The error messages could even be compressed to reduce the noise:
test.d(3,12): Error: pure nothrow @safe @nogc function 'D main' cannot call
impure non-nothrow @system non- at nogc function 'std.stdio.writeln!(int).writeln'
--
    
    
More information about the Digitalmars-d-bugs
mailing list