[Issue 18540] New: [scope] incorrect "escapes a reference to parameter e, perhaps annotate with return"

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Feb 28 20:45:42 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=18540

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

--


More information about the Digitalmars-d-bugs mailing list