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

Walter Bright <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |[email protected]
         Resolution|---                         |INVALID

--- Comment #4 from Walter Bright <[email protected]> ---
Let's do a little rewriting:

----
struct Range { Container *self; }

struct Container {
    int* p;

    static Range range(return scope ref Container c) @safe {
        return Range(&c);
    }
}
----

which produces the same error. More rewrites:

----
struct Range { Container *self; }

struct Container { int* p; }

Range range(return scope ref Container c) @safe {
    return Range(&c);
}
----

produces the same error. More:

----
struct Container { int* p; }

Container* range(return scope ref Container c) @safe {
    return &c;
}
----

produces the same error. More:

----
int** range(return scope ref int* c) @safe {
    return &c;
}
----

produces the same error:

Error: cannot take address of ref parameter c in @safe function range

Now, the return value is not `ref`, so the `return` applies to the `int*`, not
the `ref`. But we're not returning the `int*`, we're returning the address of
the `int*` and recall the `return` doesn't apply to that, hence the error.

--

Reply via email to