Bug 12939 – More uniform error messages for not nothrow and not @safe functions

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-06-17T17:26:00Z
Last change time
2016-10-01T11:47:32Z
Keywords
diagnostic, safe
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2014-06-17T17:26:41Z
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'
Comment #1 by bugzilla — 2016-06-07T08:33:53Z
Comment #2 by github-bugzilla — 2016-06-16T20:20:24Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/72e82e63d478b6f6d095255b020169a25b12154e partially address Issue 12939 https://github.com/dlang/dmd/commit/35909fa6a77177147559255737517e041d4ff014 Merge pull request #5846 from WalterBright/fix12939 partially address Issue 12939
Comment #3 by github-bugzilla — 2016-10-01T11:47:32Z