Bug 24035 – Changing this for classes is allowed in contracts

Status
NEW
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-07-06T15:41:34Z
Last change time
2024-12-13T19:30:04Z
Keywords
accepts-invalid
Assigned to
No Owner
Creator
Tim
See also
https://issues.dlang.org/show_bug.cgi?id=24024
Moved to GitHub: dmd#20309 →

Comments

Comment #0 by tim.dlang — 2023-07-06T15:41:34Z
Pull request https://github.com/dlang/dmd/pull/15389 for issue 24024 allows to modify `this` for classes inside functions. This is now also allowed inside contracts, which is inconsistent with other parameters. import std.stdio; class C { void f(int i) in { this = null; // OK //i = 5; // Error: cannot modify parameter `i` in contract } do { writeln(cast(void*)this); // prints null } } void main() { C c = new C; c.f(1); }
Comment #1 by robert.schadek — 2024-12-13T19:30:04Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20309 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB