@@ -1017,6 +1017,14 @@ split_to_next_qualifier(Rest = [Head | Tail], Filters) ->
10171017 {lists :reverse (Filters ), Rest };
10181018 {m_generate , _ , _ , _ } ->
10191019 {lists :reverse (Filters ), Rest };
1020+ {generate_strict , _ , _ , _ } ->
1021+ {lists :reverse (Filters ), Rest };
1022+ {b_generate_strict , _ , _ , _ } ->
1023+ {lists :reverse (Filters ), Rest };
1024+ {m_generate_strict , _ , _ , _ } ->
1025+ {lists :reverse (Filters ), Rest };
1026+ {zip , _ , _ } ->
1027+ {lists :reverse (Filters ), Rest };
10201028 _ ->
10211029 % eqwalizer:ignore incompatible_types needs a deeper fix for otp 28
10221030 case erl_lint :is_guard_test (Head ) of
@@ -1029,9 +1037,11 @@ split_to_next_qualifier(Rest = [Head | Tail], Filters) ->
10291037rewrite_qualifier ([], Body , [RecursiveCall ]) ->
10301038 Anno = element (2 , RecursiveCall ),
10311039 {cons , Anno , Body , RecursiveCall };
1032- rewrite_qualifier ([Head = {generate , Anno , Pattern , ListExpr } | Tail0 ], Body , EmptyClauseBody ) ->
1040+ rewrite_qualifier ([{GenType , Anno , Pattern , ListExpr } | Tail0 ], Body , EmptyClauseBody ) when
1041+ GenType == generate ; GenType == generate_strict
1042+ ->
10331043 {Guards , Tail } = split_to_next_qualifier (Tail0 , []),
1034- Suffix = expr_hash (Head ),
1044+ Suffix = expr_hash ({ generate , Anno , Pattern , ListExpr } ),
10351045 GenLc = list_to_atom (" GenLc" ++ Suffix ),
10361046 GenLcVar = {var , Anno , GenLc },
10371047 TailVar = {var , Anno , list_to_atom (" GenlcTail" ++ Suffix )},
@@ -1044,22 +1054,33 @@ rewrite_qualifier([Head = {generate, Anno, Pattern, ListExpr} | Tail0], Body, Em
10441054 ]},
10451055 % GenLc([_ | TailVar]) -> GenLc(TailVar);
10461056 FallbackClause = {clause , Anno , [{cons , Anno , {var , Anno , '_' }, TailVar }], [], [{call , Anno , GenLcVar , [TailVar ]}]},
1047- Clauses = [EmptyClause , MainClause , FallbackClause ],
1057+ Clauses =
1058+ case GenType of
1059+ generate_strict -> [EmptyClause , MainClause ];
1060+ generate -> [EmptyClause , MainClause , FallbackClause ]
1061+ end ,
10481062 {call , Anno , {named_fun , Anno , GenLc , Clauses }, [ListExpr ]};
10491063rewrite_qualifier (
10501064 [
1051- {m_generate , Anno , {map_field_exact , _Anno , K , V }, MapExpr }
1065+ {MGenType , Anno , {map_field_exact , _Anno , K , V }, MapExpr }
10521066 | Tail0
10531067 ],
10541068 Body ,
10551069 EmptyClauseBody
1056- ) ->
1070+ ) when MGenType == m_generate ; MGenType == m_generate_strict ->
10571071 ToListExpr = {call , Anno , {remote , Anno , ? ATOM (modeled_taint_maps ), ? ATOM (to_list )}, [MapExpr ]},
10581072 TuplePattern = ? TUPLE ([K , V ]),
1059- rewrite_qualifier ([{generate , Anno , TuplePattern , ToListExpr } | Tail0 ], Body , EmptyClauseBody );
1060- rewrite_qualifier ([Head = {b_generate , Anno , Pattern , BinaryExpr } | Tail0 ], Body , EmptyClauseBody ) ->
1073+ GenType =
1074+ case MGenType of
1075+ m_generate -> generate ;
1076+ m_generate_strict -> generate_strict
1077+ end ,
1078+ rewrite_qualifier ([{GenType , Anno , TuplePattern , ToListExpr } | Tail0 ], Body , EmptyClauseBody );
1079+ rewrite_qualifier ([{BGenType , Anno , Pattern , BinaryExpr } | Tail0 ], Body , EmptyClauseBody ) when
1080+ BGenType == b_generate ; BGenType == b_generate_strict
1081+ ->
10611082 {Guards , Tail } = split_to_next_qualifier (Tail0 , []),
1062- Suffix = expr_hash (Head ),
1083+ Suffix = expr_hash ({ b_generate , Anno , Pattern , BinaryExpr } ),
10631084 BinGenLc = list_to_atom (" BinGenLc" ++ Suffix ),
10641085 BinGenLcVar = {var , Anno , BinGenLc },
10651086 TailVar = {var , Anno , list_to_atom (" BinGenLcTail" ++ Suffix )},
@@ -1075,8 +1096,43 @@ rewrite_qualifier([Head = {b_generate, Anno, Pattern, BinaryExpr} | Tail0], Body
10751096 FallbackClause = {clause , Anno , [MainPattern ], [], [{call , Anno , BinGenLcVar , [TailVar ]}]},
10761097 % GenLc(<<_>>) -> <EmptyClauseBody>;
10771098 EmptyClause = {clause , Anno , [{bin , Anno , [TailSegment ]}], [], EmptyClauseBody },
1078- Clauses = [MainClause , FallbackClause , EmptyClause ],
1099+ Clauses =
1100+ case BGenType of
1101+ b_generate_strict -> [MainClause , EmptyClause ];
1102+ b_generate -> [MainClause , FallbackClause , EmptyClause ]
1103+ end ,
10791104 {call , Anno , {named_fun , Anno , BinGenLc , Clauses }, [BinaryExpr ]};
1105+ % eqwalizer:fixme type fix not yet in release https://github.com/erlang/otp/pull/10040
1106+ rewrite_qualifier ([{zip , Anno , Generators } | Tail0 ], Body , EmptyClauseBody ) ->
1107+ {Patterns , ListExprs } = lists :unzip ([
1108+ case Gen of
1109+ {generate , _ , P , E } ->
1110+ {P , E };
1111+ {generate_strict , _ , P , E } ->
1112+ {P , E };
1113+ {b_generate , _ , P , E } ->
1114+ {P , E };
1115+ {b_generate_strict , _ , P , E } ->
1116+ {P , E };
1117+ {m_generate , _ , {map_field_exact , _ , K , V }, E } ->
1118+ ToListE = {call , Anno , {remote , Anno , ? ATOM (modeled_taint_maps ), ? ATOM (to_list )}, [E ]},
1119+ {? TUPLE ([K , V ]), ToListE };
1120+ {m_generate_strict , _ , {map_field_exact , _ , K , V }, E } ->
1121+ ToListE = {call , Anno , {remote , Anno , ? ATOM (modeled_taint_maps ), ? ATOM (to_list )}, [E ]},
1122+ {? TUPLE ([K , V ]), ToListE }
1123+ end
1124+ || Gen <- Generators
1125+ ]),
1126+ TuplePattern = ? TUPLE (Patterns ),
1127+ ZippedExpr =
1128+ case ListExprs of
1129+ [E1 , E2 ] ->
1130+ {call , Anno , {remote , Anno , ? ATOM (lists ), ? ATOM (zip )}, [E1 , E2 ]};
1131+ _ ->
1132+ ListOfLists = list_to_list_ast (Anno , ListExprs ),
1133+ {call , Anno , {remote , Anno , ? ATOM (lists ), ? ATOM (zip )}, [ListOfLists ]}
1134+ end ,
1135+ rewrite_qualifier ([{generate_strict , Anno , TuplePattern , ZippedExpr } | Tail0 ], Body , EmptyClauseBody );
10801136rewrite_qualifier ([BoolExpr | Tail ], Body , EmptyClauseBody ) ->
10811137 Anno = element (2 , lists :nth (1 , EmptyClauseBody )),
10821138 TrueClause = {clause , Anno , [? ATOM (true )], [], [rewrite_qualifier (Tail , Body , EmptyClauseBody )]},
0 commit comments