|
27 | 27 | cons/1,tuple/1, |
28 | 28 | record_float/1,binary_float/1,float_compare/1,float_overflow/1, |
29 | 29 | arity_checks/1,elixir_binaries/1,find_best/1, |
30 | | - test_size/1,cover_lists_functions/1,list_append/1,bad_binary_unit/1, |
| 30 | + test_size/1,cover_lists_functions/1,list_append/1,lists_mapfold/1, |
| 31 | + bad_binary_unit/1, |
31 | 32 | none_argument/1,success_type_oscillation/1,type_subtraction/1, |
32 | 33 | container_subtraction/1,is_list_opt/1,connected_tuple_elements/1, |
33 | 34 | switch_fail_inference/1,failures/1, |
@@ -63,6 +64,7 @@ groups() -> |
63 | 64 | test_size, |
64 | 65 | cover_lists_functions, |
65 | 66 | list_append, |
| 67 | + lists_mapfold, |
66 | 68 | bad_binary_unit, |
67 | 69 | none_argument, |
68 | 70 | success_type_oscillation, |
@@ -1014,6 +1016,27 @@ list_append(_Config) -> |
1014 | 1016 | hello = id([]) ++ id(hello), |
1015 | 1017 | ok. |
1016 | 1018 |
|
| 1019 | +%% GH-10354: Type inference broke when the fun passed to mapfoldl/mapfoldr |
| 1020 | +%% returned a union of 2-tuples. |
| 1021 | +lists_mapfold(_Config) -> |
| 1022 | + expected_result = id(lists_mapfold_1()), |
| 1023 | + ok. |
| 1024 | + |
| 1025 | +lists_mapfold_1() -> |
| 1026 | + List = [{key,[{number,1}]}], |
| 1027 | + {_, FinalAcc} = |
| 1028 | + lists:mapfoldl( |
| 1029 | + fun({_, PropListItem}, Acc) -> |
| 1030 | + Number = proplists:get_value(number, PropListItem), |
| 1031 | + case Number > 0 of |
| 1032 | + true -> |
| 1033 | + {false, Acc ++ [expected_result]}; |
| 1034 | + _ -> |
| 1035 | + {true, Acc} |
| 1036 | + end |
| 1037 | + end, [], List), |
| 1038 | + hd(FinalAcc). |
| 1039 | + |
1017 | 1040 | %% OTP-15872: The compiler would treat the "Unit" of bs_init instructions as |
1018 | 1041 | %% the unit of the result instead of the required unit of the input, causing |
1019 | 1042 | %% is_binary checks to be wrongly optimized away. |
|
0 commit comments