[Issue 19143] New: error or warn when assigning `this.foo = foo` when the lone foo is this.foo (i.e.not a constructor parameter)
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Aug 6 08:46:33 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=19143
Issue ID: 19143
Summary: error or warn when assigning `this.foo = foo` when the
lone foo is this.foo (i.e.not a constructor parameter)
Product: D
Version: D2
Hardware: x86
OS: Mac OS X
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: iamthewilsonator at hotmail.com
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).
--
More information about the Digitalmars-d-bugs
mailing list