Bug 14343 – Postfix increment doesn't work on structs with immutable member

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-03-26T09:05:00Z
Last change time
2015-06-17T21:03:15Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
dransic

Comments

Comment #0 by dransic — 2015-03-26T09:05:25Z
struct S { int i; immutable(Object) o; S opUnary(string op)() { return this; } void opAssign(S other) {} } void main() { S s, t; t = s; // OK ++s; // OK s++; // Error: cannot modify struct s S with immutable members }
Comment #1 by dransic — 2015-03-26T09:07:22Z
The problem doesn't show with the old operator overloading methods: struct S { int i; immutable(Object) o; void opAddAssign(int j) { i += j; } S opPostInc() { ++i; return this; } void opAssign(S other) {} } unittest { S s; ++s; assert(s.i == 1); s++; assert(s.i == 2); }
Comment #2 by k.hara.pg — 2015-03-27T15:42:13Z
Comment #3 by github-bugzilla — 2015-03-31T19:55:24Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/30219cc6a1a647eb39e033342fa29a28a4da30fe fix Issue 14343 - Postfix increment doesn't work on structs with immutable member https://github.com/D-Programming-Language/dmd/commit/9ea13cfb5cd904b0586b0209e70bec484e16fef6 Merge pull request #4522 from 9rnsr/fix14343 Issue 14343 - Postfix increment doesn't work on structs with immutable member
Comment #4 by dlang-bugzilla — 2015-05-16T18:46:55Z
*** Issue 14589 has been marked as a duplicate of this issue. ***
Comment #5 by github-bugzilla — 2015-06-17T21:03:15Z
Commits pushed to stable at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/30219cc6a1a647eb39e033342fa29a28a4da30fe fix Issue 14343 - Postfix increment doesn't work on structs with immutable member https://github.com/D-Programming-Language/dmd/commit/9ea13cfb5cd904b0586b0209e70bec484e16fef6 Merge pull request #4522 from 9rnsr/fix14343