www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21043] New: Diagnostic for autogenerated opAssign needs to

https://issues.dlang.org/show_bug.cgi?id=21043

          Issue ID: 21043
           Summary: Diagnostic for autogenerated opAssign needs to improve
           Product: D
           Version: D2
          Hardware: x86
                OS: All
            Status: NEW
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: andrej.mitrovich gmail.com

-----
struct S
{
    ~this () { }
}

void main ()  safe
{
    S[int] map;
    map[1] = S.init;
}
-----

$ dmd test.d
 test.d(9): Error:  safe function D main cannot call  system generated function
test.S.opAssign
 test.d(1):        test.S.opAssign is declared here
This doesn't actually say where the problem is. The issue is the system destructor. Marking that destructor safe solves the issue. Maybe the diagnostic should say that. --
Jul 12 2020