www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9256] New: A purity-related error message in case of member access

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

           Summary: A purity-related error message in case of member
                    access
           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-01-01 20:55:15 PST ---
struct Foo {
    int x;
}
void main() pure {
    int y = Foo.x;
}


With DMD 2.061 gives this error message:

test.d(5): Error: pure nested function 'main' cannot access mutable data 'x'


But I think a better error message should be something like:

test.d(5): Error: need 'this' to access member x

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 01 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9256



--- Comment #1 from bearophile_hugs eml.cc 2013-01-01 20:57:36 PST ---
See also:


struct Foo {
    int x;
}
void main() pure {
    int y = Foo.x.max;
}


test3.d(5): Error: pure nested function 'main' cannot access mutable data 'x'

But I think this problem is elsewhere in Bugzilla.

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