digitalmars.D.bugs - [Issue 20170] New: [dip1000] scope and return not inferred for auto
- d-bugmail puremagic.com (34/34) Aug 26 2019 https://issues.dlang.org/show_bug.cgi?id=20170
https://issues.dlang.org/show_bug.cgi?id=20170 Issue ID: 20170 Summary: [dip1000] scope and return not inferred for auto ref parameter Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: snarwin+bugzilla gmail.com struct S { string value; safe this()(auto ref string val) { value = val; } } safe S create(return string arg) { return S(arg); } --- The example above fails to compile, with the following error: Error: returning `S(null).this(arg)` escapes a reference to parameter `arg`, perhaps annotate with `return` Adding `scope return` to the constructor's parameter allows the example to compile successfully, which suggests that they are not being correctly inferred, even though the constructor is a template. --
Aug 26 2019