Bug 14721 – Contracts should not be able to modify function arguments

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-06-23T08:46:04Z
Last change time
2024-12-13T18:43:33Z
Keywords
accepts-invalid
Assigned to
No Owner
Creator
Denis Shelomovskii
Moved to GitHub: dmd#19009 →

Comments

Comment #0 by verylonglogin.reg — 2015-06-23T08:46:04Z
This code compiles but shouldn't: --- void f(int[] arr) in { arr[0] = 5; } // compiles, should be an error body { } class C { int i; void f() in { i = 5; } // compiles, should be an error body { } } --- Notes: `invariant` doesn't allow modification of class fields as `this` is `const` and function result passed to `out` contract is `const` too. For `in`/`out` contracts only direct assignment to parameter is rejected (Issue 9413 & Issue 9414).
Comment #1 by robert.schadek — 2024-12-13T18:43:33Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19009 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB