Bug 11291 – Disallow mutation of a const variable

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-10-18T03:07:00Z
Last change time
2013-11-03T08:31:07Z
Keywords
accepts-invalid, pull
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2013-10-18T03:07:03Z
With dmd 2.064beta2 this gives no compile-time errors: import std.range: zip; void main() { foreach (const a, const b; zip(["foo"], ["bar"])) { a = "something"; } } But I expect it to give a "cannot modify const expression a" error.
Comment #1 by k.hara.pg — 2013-10-18T04:35:45Z
Comment #2 by bearophile_hugs — 2013-10-18T04:49:25Z
You are really good Kenji.
Comment #3 by github-bugzilla — 2013-11-03T08:26:50Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/d826696f214166a07371c4401e3a1d6e27bd5082 fix Issue 11291 - Disallow mutation of a const variable https://github.com/D-Programming-Language/dmd/commit/1c0f7a2c7cc4943076d5bd5d30c31dc19fd7ef0b Merge pull request #2678 from 9rnsr/fix11291 Issue 11291 - Disallow mutation of a const variable