Bug 20170 – [dip1000] scope and return not inferred for auto ref parameter

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2019-08-26T16:30:17Z
Last change time
2020-06-13T21:05:51Z
Assigned to
No Owner
Creator
Paul Backus

Comments

Comment #0 by snarwin+bugzilla — 2019-08-26T16:30:17Z
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.
Comment #1 by snarwin+bugzilla — 2020-06-13T21:05:51Z
As of DMD v2.092.0 the given example compiles without errors.