Bug 23917 – "ref" in alias this call not detected in "auto ref" return resolution

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-05-12T17:54:15Z
Last change time
2024-12-13T19:28:55Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
Vladimir Panteleev
Moved to GitHub: dmd#18167 →

Comments

Comment #0 by dlang-bugzilla — 2023-05-12T17:54:15Z
////////////////////// test.d ///////////////////// struct NC { @disable this(this); } struct S { struct A { @property ref NC value() { assert(false); } alias value this; } A a; auto ref NC get() return { return a; } } /////////////////////////////////////////////////// Compiler says: test.d(14): Error: struct `test.NC` is not copyable because it has a disabled postblit However, changing "auto ref" to "ref" makes it work.
Comment #1 by dlang-bugzilla — 2023-05-12T18:03:02Z
Something weird also happens when you try to pass it as a parameter to a ref function. A non-templated function works, but a function templated on the argument/return type fails! ///////////////////// test.d //////////////////// struct NC { @disable this(this); } struct A { @property ref NC value() { assert(false); } alias value this; } A a; ref NC f1(ref return NC value) { return value; } auto ref NC get1() { return f1(a); } // OK ref T f2(T)(ref return T value) { return value; } auto ref NC get2() { return f2(a); } // Error /////////////////////////////////////////////////
Comment #2 by dlang-bugzilla — 2023-05-12T20:55:14Z
(Oops, ignore above comment, got my return types mixed up.)
Comment #3 by robert.schadek — 2024-12-13T19:28:55Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18167 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB