warn on variable hiding

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

warn on variable hiding

David Collier
Is there anything I can do to get the interpreter to issue a warning when
I hide a variable?

I almost never mean to do it and it's a real source of wasted time!

TVM

David

Reply | Threaded
Open this post in threaded view
|

RE: warn on variable hiding

Thijs Schreijer
> On Behalf Of David Collier
> Sent: dinsdag 16 oktober 2012 16:05
> Subject: warn on variable hiding
>
> Is there anything I can do to get the interpreter to issue a warning
> when I hide a variable?
>
> I almost never mean to do it and it's a real source of wasted time!
>

That would incur runtime cost. ZeroBrano Studio code analysis feature will
detect it, just one <shift><F7> key press away (as a bonus it checks several
others as well, global assign, unused locals, etc.)



Reply | Threaded
Open this post in threaded view
|

Re: warn on variable hiding

Matthew Wild
In reply to this post by David Collier
On 16 October 2012 15:05, David Collier <[hidden email]> wrote:
> Is there anything I can do to get the interpreter to issue a warning when
> I hide a variable?
>
> I almost never mean to do it and it's a real source of wasted time!

What do you mean by "hide a variable"? Do you mean shadowing, as in:

    local foo = 1
    -- code here
   local foo = "something else"

Perhaps? If this is the case, I highly recommend lua-inspect to catch
things like this, and more: https://github.com/davidm/lua-inspect

Regards,
Matthew

Reply | Threaded
Open this post in threaded view
|

Re: warn on variable hiding

Jorge Visca
In reply to this post by David Collier
lua-inspect does that (and more). That thing should be integrated in
every single editor used to work with lua.

Jorge

On 16/10/12 12:05, David Collier wrote:
> Is there anything I can do to get the interpreter to issue a warning when
> I hide a variable?
>
> I almost never mean to do it and it's a real source of wasted time!
>
> TVM
>
> David
>


Reply | Threaded
Open this post in threaded view
|

Re: warn on variable hiding

Dirk Laurie-2
2012/10/16 Jorge <[hidden email]>:
> lua-inspect does that (and more). That thing should be integrated in every
> single editor used to work with lua.

It slows down gvim to the point of annoyance, so I prefer to
run lua-inspect from the command line.

Reply | Threaded
Open this post in threaded view
|

Re: warn on variable hiding

Jorge Visca
On 16/10/12 15:46, Dirk Laurie wrote:
> 2012/10/16 Jorge <[hidden email]>:
>> lua-inspect does that (and more). That thing should be integrated in every
>> single editor used to work with lua.
>
> It slows down gvim to the point of annoyance, so I prefer to
> run lua-inspect from the command line.
>

I've seen that in gvim, true. But it doesn't in scite. What it does in
scite is randomly stop working, until I close and reopen it.

Someone should do it right :)

Jorge