Bug 2780 – Regression(2.027) ref Return Allows modification of immutable data

Status
RESOLVED
Resolution
DUPLICATE
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2009-04-01T14:47:00Z
Last change time
2015-06-09T01:18:03Z
Keywords
accepts-invalid
Assigned to
nobody
Creator
dsimcha
Blocks
2573

Comments

Comment #0 by dsimcha — 2009-04-01T14:47:50Z
import std.stdio; struct Immutable { immutable uint[2] num; ref uint opIndex(uint index) immutable { return num[index]; } } void main() { immutable Immutable foo; writeln(foo[0]); // Prints 0. foo[0]++; writeln(foo[0]); // Prints 1. } Probably related to the fix for bug 2728 because the weird error message provided by 2728 was what used to prevent this bug from happening.
Comment #1 by k.hara.pg — 2011-06-17T02:59:15Z
*** This issue has been marked as a duplicate of issue 2521 ***