Bug 23096 – return auto ref does wrongly inferred with member function

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2022-05-06T12:08:46Z
Last change time
2024-12-13T19:22:41Z
Assigned to
No Owner
Creator
João Lourenço
Moved to GitHub: dmd#20099 →

Comments

Comment #0 by jlourenco5691 — 2022-05-06T12:08:46Z
The member function returns a ref instead of an lvalue. ``` struct Foo { auto ref get() { return i; } int i; } auto ref get()(auto ref Foo foo) { return foo.i; } void main() { static assert(!__traits(compiles, &get(Foo(4)))); // ok static assert(!__traits(compiles, &Foo(4).get())); // fails } ``` This probably happens because this bit of code does not fail also ``` struct Foo { ref get() { return i; } int i; } void main() { auto p = &Foo(4).get; } ```
Comment #1 by robert.schadek — 2024-12-13T19:22:41Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20099 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB