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

          Issue ID: 23124
           Summary: [dip1000] scope and return should not be inferred for
                    @trusted function
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: [email protected]
          Reporter: [email protected]

This should compile, but does not.
----------
struct MyType
{ private @system int* _content;
  // This type is designed so that _content will never point to local data.
  @trusted pure this(return ref int i){_content = new int(i);}
  // Note, not marked RETURN scope. Should return an unscoped pointer.
  @trusted pure scope content(){return _content;}
}

@safe void main()
{ int* outer;
  if(true)
  { int inner;
    // Inferred as scope, which is intended
    auto myVar = MyType(inner);
    // Should be allowed
    outer = myVar.content;
  }
}
----------

More through explaination:
https://forum.dlang.org/thread/[email protected]

--

Reply via email to