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: nob...@puremagic.com
          Reporter: bearophile_h...@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-@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-@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-@nogc function 'std.stdio.writeln!(int).writeln'

--

Reply via email to