digitalmars.D.bugs - [Issue 21748] New: Return value of forward-referenced auto ref
- d-bugmail puremagic.com (42/42) Mar 22 2021 https://issues.dlang.org/show_bug.cgi?id=21748
https://issues.dlang.org/show_bug.cgi?id=21748 Issue ID: 21748 Summary: Return value of forward-referenced auto ref function mistakenly treated as lvalue Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: snarwin+bugzilla gmail.com As of DMD 2.096.0, the following program compiles and runs without error: --- void main() { fun() = 1; } auto ref int fun() { return 42; } --- However, if the order of the functions is swapped: --- auto ref int fun() { return 42; } void main() { fun() = 1; } --- ...then the compiler correctly issues the following error: --- bug.d(8): Error: `fun()` is not an lvalue and cannot be modified --- --
Mar 22 2021