@@ -44,6 +44,7 @@ translate({ in, Meta, [Left, Right] }, #elixir_scope{extra_guards=nil} = S) ->
4444 { TExpr , TS };
4545
4646translate ({ in , Meta , [Left , Right ] }, # elixir_scope {extra_guards = Extra } = S ) ->
47+ elixir_errors :deprecation (Meta , S # elixir_scope .file , " in operator inside matches is deprecated, please move it to a guard" ),
4748 { TVar , TExpr , TS } = translate_in (Meta , Left , Right , S ),
4849 { TVar , TS # elixir_scope {extra_guards = [TExpr |Extra ]} };
4950
@@ -281,8 +282,18 @@ decreasing_compare(Line, Var, Start, End) ->
281282 { op , Line , '=<' , Var , Start },
282283 { op , Line , '>=' , Var , End } }.
283284
284- rewrite_case_clauses ([{do ,Meta1 ,[{in ,_ ,[{'_' ,_ ,_ },[false ,nil ]]}],False },{do ,Meta2 ,[{'_' ,_ ,_ }],True }]) ->
285- [{do ,Meta1 ,[false ],False },{do ,Meta2 ,[true ],True }];
285+ % % TODO: Once we have elixir_exp, we can move this
286+ % % clause to Elixir code and out of case.
287+ rewrite_case_clauses ([
288+ {do ,Meta1 ,[{'when' ,_ ,[{V ,M ,C },{in ,_ ,[{V ,M ,C },[false ,nil ]]}]}],False },
289+ {do ,Meta2 ,[{'_' ,_ ,UC }],True }] = Clauses )
290+ when is_atom (V ), is_list (M ), is_atom (C ), is_atom (UC ) ->
291+ case lists :keyfind ('cond' , 1 , M ) of
292+ { 'cond' , true } ->
293+ [{do ,Meta1 ,[false ],False },{do ,Meta2 ,[true ],True }];
294+ _ ->
295+ Clauses
296+ end ;
286297
287298rewrite_case_clauses (Clauses ) ->
288299 Clauses .
0 commit comments