[Issue 23124] New: [dip1000] scope and return should not be inferred for @trusted function

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu May 19 07:18:32 UTC 2022


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: nobody at puremagic.com
          Reporter: Ajieskola at gmail.com

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/edtbjavjzkwogvutxpho@forum.dlang.org

--


More information about the Digitalmars-d-bugs mailing list