www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18540] New: [scope] incorrect "escapes a reference to


          Issue ID: 18540
           Summary: [scope] incorrect "escapes a reference to parameter e,
                    perhaps annotate with return"
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: safe
          Severity: normal
          Priority: P2
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: code dawg.eu

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());
dmd -c bug.d
Error: returning Interpreter(move(e), S(null)) escapes a reference to parameter
e, perhaps annotate with return

Feb 28 2018