@@ -458,26 +458,26 @@ defmodule Module.Types.Pattern do
458458
459459 # left = right
460460 defp of_pattern ( { := , _meta , [ _ , _ ] } = match , path , stack , context ) do
461- { match , version , var } =
461+ { matches , version , var } =
462462 match
463463 |> unpack_match ( [ ] )
464464 |> Enum . split_while ( & ( not is_versioned_var ( & 1 ) ) )
465465 |> case do
466- { match , [ ] } ->
466+ { matches , [ ] } ->
467467 version = make_ref ( )
468- { match , version , { :match , [ version: version ] , __MODULE__ } }
468+ { matches , version , { :match , [ version: version ] , __MODULE__ } }
469469
470470 { pre , [ { _ , meta , _ } = var | post ] } ->
471471 version = Keyword . fetch! ( meta , :version )
472472 { pre ++ post , version , var }
473473 end
474474
475475 # Pass the current path to build the current var
476- { expr , context } = of_var ( var , version , path , context )
477- root = % { root: { :var , version } , expr: expr }
476+ context = of_var ( var , version , path , context )
477+ root = % { root: { :var , version } , expr: match }
478478
479479 { static , dynamic , context } =
480- Enum . reduce ( match , { [ ] , [ ] , context } , fn pattern , { static , dynamic , context } ->
480+ Enum . reduce ( matches , { [ ] , [ ] , context } , fn pattern , { static , dynamic , context } ->
481481 { type , context } = of_pattern ( pattern , [ root ] , stack , context )
482482
483483 if is_descr ( type ) do
@@ -491,14 +491,13 @@ defmodule Module.Types.Pattern do
491491 { Enum . reduce ( static , & intersection / 2 ) , context }
492492 else
493493 # The dynamic parts have to be recomputed whenever they change
494- { var , context } =
495- of_pattern ( var , [ % { root: { :intersection , dynamic } , expr: expr } ] , stack , context )
494+ context = of_var ( var , version , [ % { root: { :intersection , dynamic } , expr: match } ] , context )
496495
497- # But the static parts we push down as part of the argument intersection
496+ # And everything else is also pushed as part of the argument intersection
498497 if static == [ ] do
499- { var , context }
498+ { { :intersection , dynamic } , context }
500499 else
501- { { :intersection , [ var , Enum . reduce ( static , & intersection / 2 ) ] } , context }
500+ { { :intersection , [ Enum . reduce ( static , & intersection / 2 ) | dynamic ] } , context }
502501 end
503502 end
504503 end
@@ -601,8 +600,7 @@ defmodule Module.Types.Pattern do
601600 defp of_pattern ( { name , meta , ctx } = var , path , _stack , context )
602601 when is_atom ( name ) and is_atom ( ctx ) do
603602 version = Keyword . fetch! ( meta , :version )
604- { _ , context } = of_var ( var , version , path , context )
605- { { :var , version } , context }
603+ { { :var , version } , of_var ( var , version , path , context ) }
606604 end
607605
608606 defp is_versioned_var ( { name , _meta , ctx } ) when is_atom ( name ) and is_atom ( ctx ) and name != :_ ,
@@ -636,7 +634,7 @@ defmodule Module.Types.Pattern do
636634 { args_paths , vars_paths , vars_deps }
637635 end
638636
639- { expr , % { context | pattern_info: pattern_info } }
637+ % { context | pattern_info: pattern_info }
640638 end
641639
642640 # TODO: Properly traverse domain keys
0 commit comments