www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9620] New: Error messages of failed pure enforcement


           Summary: Error messages of failed pure enforcement
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: diagnostic
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc

--- Comment #0 from bearophile_hugs eml.cc 2013-02-28 19:59:45 PST ---
I don't know if this is a bug, or if it's OK.

This is wrong code:

import std.range: chain;
void main() pure {
    static void foo() {
        int[] a;
        chain(a, a);

DMD 2.063alpha gives:

test1.d(5): Error: pure function 'main' cannot call impure function 'chain'

Is it right for the error message to say that main calls chain (while it's
called by foo)?

This similar code is a simpler example:

void foo(int[]) {}
void main() pure {
    static void bar() {
        int[] a;

It gives:

test2.d(5): Error: pure function 'D main' cannot call impure function

Note how in the first error message dmd uses 'main' and in the second 'D main'.
I don't know why there is such difference.

Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 28 2013