@@ -77,9 +77,9 @@ translate_each({ '__op__', Line, [Op, Left, Right] }, S) when is_atom(Op) ->
7777 { { op , Line , convert_op (Op ), TLeft , TRight }, NS };
7878
7979translate_each ({ '__ambiguousop__' , Line , [Var , H |T ] }, S ) ->
80- { Name , _ , _ } = Var ,
80+ { Name , _ , Kind } = Var ,
8181
82- case orddict :find (Name , S # elixir_scope .vars ) of
82+ case orddict :find ({ Name , Kind } , S # elixir_scope .vars ) of
8383 error -> translate_each ({ Name , Line , [H |T ] }, S );
8484 _ ->
8585 case T of
@@ -103,7 +103,7 @@ translate_each({ alias, Line, [Ref, KV] }, S) ->
103103 { atom , _ , Old } ->
104104 { New , SF } = case lists :keyfind (as , 1 , KV ) of
105105 Opt when Opt == { as , true }; Opt == false ->
106- { elixir_aliases :last (Old ), SR };
106+ { elixir_aliases :last (Old ), SR };
107107 { as , false } ->
108108 { Old , SR };
109109 { as , Other } ->
@@ -284,7 +284,7 @@ translate_each({ quote, GivenLine, [T] }, S) when is_list(T) ->
284284
285285translate_each ({ quote , GivenLine , [_ ] }, S ) ->
286286 syntax_error (GivenLine , S # elixir_scope .file , " invalid args for quote" );
287-
287+
288288% % Functions
289289
290290translate_each ({ fn , Line , [[{do , { '->' , _ , Pairs }}]] }, S ) ->
@@ -330,41 +330,23 @@ translate_each({ 'super?', Line, [] }, S) ->
330330
331331% % Variables
332332
333- translate_each ({ '^' , Line , [ { Name , _ , Args } ] }, S ) ->
334- Dict = case Args of
335- nil -> S # elixir_scope .vars ;
336- quoted -> S # elixir_scope .quote_vars ;
337- _ ->
338- syntax_error (Line , S # elixir_scope .file , " cannot use ^ with expression at ^~s , ^ must be used only with variables" , [Name ])
339- end ,
340-
341- Result = case S # elixir_scope .context of
342- assign ->
343- case orddict :find (Name , Dict ) of
344- error -> " unbound variable ^~s " ;
345- { ok , Value } -> { {var , Line , Value }, S }
346- end ;
347- _ -> " cannot access variable ^~s outside of assignment"
348- end ,
333+ translate_each ({ '^' , Line , [ { Name , _ , Kind } ] }, S ) when is_list (Kind ) ->
334+ syntax_error (Line , S # elixir_scope .file , " cannot use ^ with expression at ^~s , ^ must be used only with variables" , [Name ]);
349335
350- case is_list (Result ) of
351- true ->
352- syntax_error (Line , S # elixir_scope .file , Result , [Name ]);
353- false ->
354- Result
336+ translate_each ({ '^' , Line , [ { Name , _ , Kind } ] }, # elixir_scope {context = assign } = S ) when is_atom (Kind ) ->
337+ case orddict :find ({ Name , Kind }, S # elixir_scope .vars ) of
338+ { ok , Value } ->
339+ { { var , Line , Value }, S };
340+ error ->
341+ syntax_error (Line , S # elixir_scope .file , " unbound variable ^~s " , [Name ])
355342 end ;
356343
357- translate_each ({ Name , Line , quoted }, S ) when is_atom (Name ) ->
358- NewS = S # elixir_scope {vars = S # elixir_scope .quote_vars ,noname = true },
359- { TVar , VS } = elixir_scope :translate_var (Line , Name , quoted , NewS ),
360- { TVar , VS # elixir_scope {
361- quote_vars = VS # elixir_scope .vars ,
362- noname = S # elixir_scope .noname ,
363- vars = S # elixir_scope .vars
364- } };
365-
366- translate_each ({ Name , Line , nil }, S ) when is_atom (Name ) ->
367- elixir_scope :translate_var (Line , Name , nil , S );
344+ translate_each ({ '^' , Line , [ { Name , _ , Kind } ] }, S ) when is_atom (Kind ) ->
345+ syntax_error (Line , S # elixir_scope .file ,
346+ " cannot access variable ^~s outside of assignment" , [Name ]);
347+
348+ translate_each ({ Name , Line , Kind }, S ) when is_atom (Name ), (Kind == nil orelse Kind == quoted ) ->
349+ elixir_scope :translate_var (Line , Name , Kind , S );
368350
369351% % Local calls
370352
0 commit comments