www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23073] New: [dip1000] scope inference from pure doesn't


          Issue ID: 23073
           Summary: [dip1000] scope inference from pure doesn't consider
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dkorpel live.nl


class C 
    C next;

void assignNext(C c) pure nothrow  nogc 
    c.next = c;

C escape()  nogc
    scope C c = new C();
    return c.next;

void main()
    C dangling = escape();


`assignNext` should not be callable on a `scope` parameter. The compiler sees
no other parameters that c could be assigned to, but doesn't consider that
mutable aggregates may have extra pointer layers, allowing you to escape a
scope pointer because of the lack of transitive scope.

Apr 30 2022