digitalmars.D.bugs - [Issue 19620] New: Not quite sure what immutability means
- d-bugmail puremagic.com (25/25) Jan 26 2019 https://issues.dlang.org/show_bug.cgi?id=19620
https://issues.dlang.org/show_bug.cgi?id=19620 Issue ID: 19620 Summary: Not quite sure what immutability means Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dlang.org Assignee: nobody puremagic.com Reporter: porton narod.ru https://dlang.org/spec/const3.html is not quite clear on what immutability means. If a value of an immutable object changes before the immutable-specified var appears, is it legal? Example: char[] a = new char[2]; a[0] = 'x'; a[1] = 'y'; immutable char[] b = cast(immutable char[]) a; // here we have an immutable object which was modified previously Is the above code legal? Need to say it in the specification explicitly. --
Jan 26 2019