Keep user's given name when rebinding variables

The following code:

    counter = 1
    counter = 2

Is now rewritten internally to:

    counter   = 1
    counter@1 = 2

Which gives us a couple things:

1. Better debugging
2. We can now show warnings for rebound variables not used

Elixir also keeps `_@` prefix to store internal variables
(for example, `_@1`, `_@MODULE`, etc).

Closes #607.
This commit is contained in:
José Valim
2012-11-01 12:37:08 +01:00
parent 11eb2d6d3c
commit 01f9518899
10 changed files with 52 additions and 52 deletions
+5
View File
@@ -106,6 +106,11 @@ handle_file_warning(_, File, {Line,erl_lint,{undefined_behaviour,Module}}) ->
io:format(file_format(Line, File, Message));
%% Default behavior
handle_file_warning(_, File, {Line,erl_lint,{unused_var,Var}}) ->
List = lists:takewhile(fun(X) -> X /= $@ end, atom_to_list(Var)),
Message = format_error(erl_lint, { unused_var, list_to_atom(List) }),
io:format(file_format(Line, File, Message));
handle_file_warning(_, File, {Line,Module,Desc}) ->
Message = format_error(Module, Desc),
io:format(file_format(Line, File, Message)).