[Issue 17626] Same name variable assignment should raise a compile-time warning
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sun Jul 9 05:31:43 PDT 2017
https://issues.dlang.org/show_bug.cgi?id=17626
David Baum <david at weka.io> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|Same name variable |Same name variable
|assignment should be |assignment should raise a
|prohibited |compile-time warning
--- Comment #1 from David Baum <david at weka.io> ---
I would like to suggest having the following code raise a compile-time warning:
```
x = x;
```
Other than invoking the copy constructor, this is a no-op.
I had the following piece of code, which for "some reason" didn't work:
```
struct FuncPtr{
void* ptr;
this(void* ptr){
ptr = ptr;
}
...
}
```
Locating this wasn't immediate, and I don't see valid reasons for someone to
purposely write such a code.
I suggest at least raising a compile-time warning.
Much easier than to hunt for nulls in runtime.
--
More information about the Digitalmars-d-bugs
mailing list