Bug 8148 – properties and the ternary operator

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-05-25T04:11:00Z
Last change time
2012-12-26T05:21:39Z
Assigned to
nobody
Creator
hoganmeier

Comments

Comment #0 by hoganmeier — 2012-05-25T04:11:14Z
import std.datetime; import std.stdio; void main() { Thing t; t.vPosition = (Clock.currStdTime % 2 == 0) ? Vec(2, 2) : Vec(3, 3); Vec v = t.vPosition; writeln("%d %d\n", v.x, v.y); } struct Vec { int x; int y; } struct Thing { @property Vec vPosition() { return mPosition; } @property Vec vPosition( const ref Vec value ) { return mPosition = value; } private: Vec mPosition; } $ dmd test.d test.d(7): Error: not a property t.vPosition t.vPosition = Vec(3,3); works. I think either both has to work or none.
Comment #1 by yebblies — 2012-12-26T05:21:39Z
Because struct literals are no longer lvalues, t.vPosition = Vec(3,3); doesn't work either.