Bug 18540 – [scope] incorrect "escapes a reference to parameter e, perhaps annotate with return"

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-02-28T20:45:42Z
Last change time
2018-03-15T04:54:00Z
Keywords
safe
Assigned to
No Owner
Creator
Martin Nowak

Comments

Comment #0 by code — 2018-02-28T20:45:42Z
cat > bug.d << CODE module interpreter; import std.algorithm.mutation : move; struct S { string s; } struct Interpreter(Engine) { Engine _engine; S s; } Interpreter!Engine interpreter(Engine)(return scope Engine e) @system { return Interpreter!Engine(move(e)); } struct EchoEngine { @disable this(this); } void bug() { auto intp = interpreter(EchoEngine()); } CODE ---- dmd -c bug.d ---- Error: returning Interpreter(move(e), S(null)) escapes a reference to parameter e, perhaps annotate with return
Comment #1 by bugzilla — 2018-03-03T09:28:20Z
Can this be reduced to an example that doesn't reference Phobos?
Comment #2 by bugzilla — 2018-03-15T04:54:00Z
Doesn't produce an error for master, with or without -dip1000.