[Issue 24024] cannot pass class this to ref class
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jul 5 17:14:48 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=24024
--- Comment #5 from Walter Bright <bugzilla at digitalmars.com> ---
(In reply to FeepingCreature from comment #4)
> I mean, in the extreme, if this was allowed, shouldn't this happen?
It isn't any different from:
class C
{
static void mem(C c1)
{
foo(c1);
}
}
void foo(ref C c2) { c2 = null; }
C c3 = new C;
C.mem(c3); // c1 is a copy of c3
assert(c3 is null); // c1 is set to null, not c3
> And what about if `c` is genuinely an rvalue, such as `C createC();
> createC.mem;`?
Rvalues cannot be passed by ref.
13116 created a special case, and like special cases, it works inconsistently
with the rest of the semantics.
--
More information about the Digitalmars-d-bugs
mailing list