Bug 9140 – ref foreach of immutables in postcondition

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-12-10T20:46:00Z
Last change time
2012-12-12T19:42:37Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2012-12-10T20:46:32Z
immutable(int)[] bar() out(result) { foreach (ref r; result) {} } body { return null; } void main() {} I think the error is not correct, DMD 2.061alpha gives: test.d(3): Error: variable test.bar.result cannot modify result 'result' in contract
Comment #1 by lt.infiltrator — 2012-12-10T20:52:33Z
I think that it is correct; it's just a shallow check. Try: foreach (const ref r; result) {}
Comment #2 by k.hara.pg — 2012-12-10T21:55:30Z
This is a regression caused by fixing bug 8783.
Comment #3 by k.hara.pg — 2012-12-11T01:04:36Z
Comment #4 by github-bugzilla — 2012-12-12T16:13:31Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/596fae913de2791141a6f27153fde90a7e3be08e fix Issue 9140 - ref foreach of immutables in postcondition This change reopens bug 8783. https://github.com/D-Programming-Language/dmd/commit/2284bb97158b8ca66022b28153405adc22714f73 Merge pull request #1364 from 9rnsr/fix9140 Issue 9140 - ref foreach of immutables in postcondition