>
> Is it possible to detect if a variable shadows a function, and warn in
> that case?  I really, really, REALLY don't want to write v() in iex... :)
>

Oh, I understand it now.

So going back to the cases the current warning is meant to solve that I
sent in an earlier email, warning only if it shadows a function, does not
solve the first case although it does also solve the second case.

However, it does not solve the contextual overhead, When changing or
reading code, I still need to carefully look at the surrounding context to
see if the variable is not being used in order to avoid the warning (or I
can write the code and wait for the compiler to tell me).

But to make things worse, the suggestion of only warning if there is a
function, means that by simply adding a function into a given module, you
may now get warnings on other functions in that same module, simply because
you defined a new function 100LOC below. It is even worse if you consider
imports: if you are importing or using an external library and it adds a
new function to its API, you may have warnings when updating your
dependency.

Those are really undesired consequences. I believe we should either define
that one of them has higher precedence (Elixir v1.3) or make sure they
don't conflict (Elixir v1.4).

I really, really, REALLY don't want to write v() in iex... :)
>

We are actually capable of avoiding the warning by detecting those special
variables. In fact, the same could be done in the ptest macro you posted
earlier (I believe it is a macro?). You can traverse the AST, looking for
variables and if there is no actual variable (check both __CALLER__.vars
and __CALLER__.export_vars), then you can upgrade to a call before it
reaches the Elixir compiler. That's why "foo |> bar" does not warn, because
it bar becomes bar/1 before the compiler parses the code.

I will open up an issue to discuss if we should do so in IEx helpers.

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4KC6Dds0aRsi-pGPkz4955O13ok3EJkLZdKPquCqDew8A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to