Code:
import std.stdio;
struct Bar {
int payload;
alias payload this;
}
struct Foo {
private {
Bar m_bar;
int m_baz;
}
@property {
Bar bar() { return m_bar; }
void bar(Bar v) { m_bar = v; }
int baz() { return m_baz; }
void baz(int v) { m_baz = v; }
}
}
void main() {
Foo foo;
foo.bar += 4; // Compiles. Why?
foo.baz += 4; // Error: foo.baz() is not an lvalue
}
foo.baz() is not lvalue. It's true.
But foo.bar() is lvalue. Why? I expected the same error. This
line has no effect, but the compiler does not issue even a
warning.
DMD64 D Compiler v2.066.1. CentOS 7