with and shadowing variables

2018-07-22 Thread Anonymouse via Digitalmars-d
Can this be made a compiler warning? struct Foo { int i; } void main() { Foo foo; with (foo) { i = 42; int i; i = 24; } } I'm hesitant to file a bug because it'll just be immediately closed with a link to https://dlang.org/spec/statement.html#WithS

Re: with and shadowing variables

2018-07-22 Thread Jonathan M Davis via Digitalmars-d
On Sunday, July 22, 2018 12:13:43 Anonymouse via Digitalmars-d wrote: > Can this be made a compiler warning? > > struct Foo > { > int i; > } > > void main() > { > Foo foo; > > with (foo) > { > i = 42; > int i; > i = 24; > } > } > > I'm hesitant to

Re: with and shadowing variables

2018-07-23 Thread Jim Balter via Digitalmars-d
On Sunday, 22 July 2018 at 12:13:43 UTC, Anonymouse wrote: Can this be made a compiler warning? struct Foo { int i; } void main() { Foo foo; with (foo) { i = 42; int i; i = 24; } } I'm hesitant to file a bug because it'll just be immediately closed

Re: with and shadowing variables

2018-07-23 Thread Jim Balter via Digitalmars-d
On Sunday, 22 July 2018 at 14:05:45 UTC, Jonathan M Davis wrote: On Sunday, July 22, 2018 12:13:43 Anonymouse via Digitalmars-d wrote: Can this be made a compiler warning? struct Foo { int i; } void main() { Foo foo; with (foo) { i = 42; int i; i

Re: with and shadowing variables

2018-07-23 Thread Anonymouse via Digitalmars-d
On Monday, 23 July 2018 at 12:01:19 UTC, Jim Balter wrote: Do you have an actual case where it was a problem, as opposed to a contrived example with semantically empty identifiers? I recently saw another comment objecting to `with` altogether as being obfuscating because you can't tell which sy

Re: with and shadowing variables

2018-07-23 Thread baz via Digitalmars-d
On Sunday, 22 July 2018 at 12:13:43 UTC, Anonymouse wrote: I'm hesitant to file a bug because it'll just be immediately closed with a link to https://dlang.org/spec/statement.html#WithStatement. I understand that's how it works, but it's weird and weak to human mistakes. IMO the only reasona

Re: with and shadowing variables

2018-07-23 Thread Steven Schveighoffer via Digitalmars-d
On 7/22/18 8:13 AM, Anonymouse wrote: Can this be made a compiler warning? struct Foo {     int i; } void main() {     Foo foo;     with (foo)     {     i = 42;     int i;     i = 24;     } } I'm hesitant to file a bug because it'll just be immediately closed with a link

Re: with and shadowing variables

2018-07-24 Thread Anonymouse via Digitalmars-d
On Monday, 23 July 2018 at 17:26:16 UTC, Steven Schveighoffer wrote: On 7/22/18 8:13 AM, Anonymouse wrote: Can this be made a compiler warning? struct Foo {     int i; } void main() {     Foo foo;     with (foo)     {     i = 42;     int i;     i = 24;     } } I'm hesitan