[Issue 18594] X is not an lvalue should have a better error message
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Sep 25 16:30:21 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=18594
Tobias Pankrath <tobias at pankrath.net> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tobias at pankrath.net
--- Comment #5 from Tobias Pankrath <tobias at pankrath.net> ---
---
struct Test(T) {
@property ref T get() inout { return member; }
private:
T member;
}
int main(string[] args)
{
Test!int t;
t.get = 12;
return t.get;
}
---
This code has an very similar issue:
> test.d(3): Error: cast(int)this.member is not an lvalue and cannot be modified
The correct definition is:
---
struct Test(T) {
@property ref inout(T) get() inout { return member; }
private:
T member;
}
---
but the error message gives no hint in that direction. It confused me quite a
bit, since IMO member is a fine lvalue that happens to be const/inout.
https://run.dlang.io/is/IJKZ80
--
More information about the Digitalmars-d-bugs
mailing list