www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6487] New: Richer impurity error message

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6487

           Summary: Richer impurity error message
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: diagnostic
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 12 2011
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6487


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrej.mitrovich gmail.com
         Resolution|                            |DUPLICATE



15:59:02 PDT ---
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 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 21 2012