Local imports hide local symbols

2014-09-23 Thread Andrei Alexandrescu via Digitalmars-d
I've raised https://issues.dlang.org/show_bug.cgi?id=10378 to critical. Please chime in with ideas for a good solution. Thanks! -- Andrei

Re: Local imports hide local symbols

2014-09-23 Thread Meta via Digitalmars-d
On Tuesday, 23 September 2014 at 18:34:51 UTC, Andrei Alexandrescu wrote: I've raised https://issues.dlang.org/show_bug.cgi?id=10378 to critical. Please chime in with ideas for a good solution. Thanks! -- Andrei What about requiring all local imports to be statically imported? module a; int

Re: Local imports hide local symbols

2014-09-23 Thread H. S. Teoh via Digitalmars-d
On Tue, Sep 23, 2014 at 11:34:51AM -0700, Andrei Alexandrescu via Digitalmars-d wrote: > I've raised https://issues.dlang.org/show_bug.cgi?id=10378 to critical. > Please chime in with ideas for a good solution. Thanks! -- Andrei I can think of a few: 1) Change lookup rules so that symbols pulled

Re: Local imports hide local symbols

2014-09-23 Thread Andrei Alexandrescu via Digitalmars-d
On 9/23/14, 11:48 AM, Meta wrote: On Tuesday, 23 September 2014 at 18:34:51 UTC, Andrei Alexandrescu wrote: I've raised https://issues.dlang.org/show_bug.cgi?id=10378 to critical. Please chime in with ideas for a good solution. Thanks! -- Andrei What about requiring all local imports to be sta

Re: Local imports hide local symbols

2014-09-23 Thread Meta via Digitalmars-d
On Tuesday, 23 September 2014 at 18:52:13 UTC, H. S. Teoh via Digitalmars-d wrote: I can think of a few: 1) Change lookup rules so that symbols pulled in by local import are found last. Walter has stated that he disagrees with this approach because it complicates symbol lookup rules. 2) Emit

Re: Local imports hide local symbols

2014-09-23 Thread H. S. Teoh via Digitalmars-d
On Tue, Sep 23, 2014 at 06:56:56PM +, Meta via Digitalmars-d wrote: > On Tuesday, 23 September 2014 at 18:52:13 UTC, H. S. Teoh via Digitalmars-d > wrote: > >I can think of a few: > > > >1) Change lookup rules so that symbols pulled in by local import are > >found last. Walter has stated that h

Re: Local imports hide local symbols

2014-09-23 Thread Peter Alexander via Digitalmars-d
On Tuesday, 23 September 2014 at 18:52:13 UTC, H. S. Teoh via Digitalmars-d wrote: 1) Change lookup rules so that symbols pulled in by local import are found last. Walter has stated that he disagrees with this approach because it complicates symbol lookup rules. This.

Re: Local imports hide local symbols

2014-09-23 Thread Andrei Alexandrescu via Digitalmars-d
On 9/23/14, 12:01 PM, H. S. Teoh via Digitalmars-d wrote: On Tue, Sep 23, 2014 at 06:56:56PM +, Meta via Digitalmars-d wrote: On Tuesday, 23 September 2014 at 18:52:13 UTC, H. S. Teoh via Digitalmars-d wrote: I can think of a few: 1) Change lookup rules so that symbols pulled in by local i

Re: Local imports hide local symbols

2014-09-23 Thread ketmar via Digitalmars-d
On Tue, 23 Sep 2014 11:50:22 -0700 "H. S. Teoh via Digitalmars-d" wrote: > (3) will likely cause backlash because it will break a LOT > of code that currently compiles and likely to have no actual > problems. we always can make a deprecation warning first. (dreaming) i want wildcard/regexp impor

Re: Local imports hide local symbols

2014-09-23 Thread H. S. Teoh via Digitalmars-d
On Tue, Sep 23, 2014 at 12:06:26PM -0700, Andrei Alexandrescu via Digitalmars-d wrote: > On 9/23/14, 12:01 PM, H. S. Teoh via Digitalmars-d wrote: > >On Tue, Sep 23, 2014 at 06:56:56PM +, Meta via Digitalmars-d wrote: > >>On Tuesday, 23 September 2014 at 18:52:13 UTC, H. S. Teoh via Digitalmar

Re: Local imports hide local symbols

2014-09-23 Thread monarch_dodra via Digitalmars-d
On Tuesday, 23 September 2014 at 19:18:08 UTC, H. S. Teoh via Digitalmars-d wrote: But this would cause a compile error: mod.d module mod; string x, y; main.d void main() { int x, y, z; import mod;

Re: Local imports hide local symbols

2014-09-23 Thread H. S. Teoh via Digitalmars-d
On Tue, Sep 23, 2014 at 07:47:59PM +, monarch_dodra via Digitalmars-d wrote: > On Tuesday, 23 September 2014 at 19:18:08 UTC, H. S. Teoh via Digitalmars-d > wrote: > >But this would cause a compile error: > > > > mod.d > > module mod; > > string x, y; > > > > main.d-

Re: Local imports hide local symbols

2014-09-23 Thread monarch_dodra via Digitalmars-d
On Tuesday, 23 September 2014 at 20:10:35 UTC, H. S. Teoh via Digitalmars-d wrote: Sounds reasonable. How would that be implemented, though? Currently, in the compiler, lookup is implemented via a linked list of Scope objects that contain, among other things, a symbol table for the symbols decl

Re: Local imports hide local symbols

2014-09-23 Thread bearophile via Digitalmars-d
Andrei Alexandrescu: I've raised https://issues.dlang.org/show_bug.cgi?id=10378 to critical. Please chime in with ideas for a good solution. Thanks! -- Andrei I think this code: import foo; void main() {} should import only the "foo" identifier in the current module/scope (or fail to do so

Re: Local imports hide local symbols

2014-09-23 Thread deadalnix via Digitalmars-d
On Tuesday, 23 September 2014 at 18:52:13 UTC, H. S. Teoh via Digitalmars-d wrote: 1) Change lookup rules so that symbols pulled in by local import are found last. Walter has stated that he disagrees with this approach because it complicates symbol lookup rules. That is dead simple compared

Re: Local imports hide local symbols

2014-09-23 Thread deadalnix via Digitalmars-d
On Tuesday, 23 September 2014 at 19:03:28 UTC, H. S. Teoh via Digitalmars-d wrote: Good luck convincing Walter, then. :-( Or maybe if we can convince Andrei to twist his arm hard enough... :-P In SDC? doing this represent ~30 lines on a 600+ line identifier resolution (plus several other hun

Re: Local imports hide local symbols

2014-09-23 Thread Brian Schott via Digitalmars-d
On Tuesday, 23 September 2014 at 18:34:51 UTC, Andrei Alexandrescu wrote: I've raised https://issues.dlang.org/show_bug.cgi?id=10378 to critical. Please chime in with ideas for a good solution. Thanks! -- Andrei In the meantime, anybody who wants to know if their code is vulnerable to this pr

Re: Local imports hide local symbols

2014-09-23 Thread Timon Gehr via Digitalmars-d
On 09/23/2014 10:19 PM, monarch_dodra wrote: As I said, local imports, IMO, should behave in all aspects as a global import. It simply only exists during its scope, but is not actually any more "internal" than the rest. If a local import creates a symbol ambiguity, then it's ambiguous, and compi

Re: Local imports hide local symbols

2014-09-23 Thread Timon Gehr via Digitalmars-d
On 09/23/2014 09:01 PM, Peter Alexander wrote: On Tuesday, 23 September 2014 at 18:52:13 UTC, H. S. Teoh via Digitalmars-d wrote: 1) Change lookup rules so that symbols pulled in by local import are found last. Walter has stated that he disagrees with this approach because it complicates symbol