Bug 19143 – error or warn when assigning `this.foo = foo` when the lone foo is this.foo (i.e.not a constructor parameter)

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Mac OS X
Creation time
2018-08-06T08:46:33Z
Last change time
2024-12-13T19:00:08Z
Assigned to
No Owner
Creator
Nicholas Wilson
Moved to GitHub: dmd#17874 →

Comments

Comment #0 by iamthewilsonator — 2018-08-06T08:46:33Z
struct Foo { int i; this (int ii) { this.i = i; } } void main() { auto foo = Foo(2); import std.stdio : writeln; writeln(foo); // prints Foo(0); } should error or at least warn. It leads to very confusing behaviours (you think i is assigned but its not).
Comment #1 by robert.schadek — 2024-12-13T19:00:08Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17874 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB