Bug 6487 – Richer impurity error message

Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-08-12T15:27:00Z
Last change time
2012-10-21T15:59:02Z
Keywords
diagnostic
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2011-08-12T15:27:15Z
When a function is not pure/safe because it calls a function present elsewhere the error message is not the best: import std.bigint, std.math; void main() { auto r = abs(BigInt(-1000)); } dmd 2.054 gives: ...\src\phobos\std\math.d(251): Error: pure function 'abs' cannot call impure function 'opCmp' ...\src\phobos\std\math.d(251): Error: safe function 'abs' cannot call system function 'opCmp' Here I'd like DMD to print something like: ...\src\phobos\std\math.d(251): Error: pure function 'abs' cannot call impure function 'std.bigint.BigInt.opCmp' Or maybe even (but this is getting a bit too much noisy): ...\src\phobos\std\math.d(251): Error: pure function 'abs' cannot call impure function '\src\phobos\std\std.bigint.BigInt.opCmp(360)' If the function is in the same module then it's better to produce a shorter printout.
Comment #1 by andrej.mitrovich — 2012-10-21T15:59:02Z
Issue 6647 and 7050 and this one will be closed after https://github.com/D-Programming-Language/dmd/pull/1201 is pulled. The message will be: Error: pure function 'std.math.abs!(BigInt).abs' cannot call impure function 'std.bigint.BigInt.opCmp!(int).opCmp' If the message is too long feel free to file another bug after it's pulled so we can tweak it, but for now it's important that we get proper info on what exact function is being called. *** This issue has been marked as a duplicate of issue 7050 ***