|
6 | 6 | -export([translate/3]).
|
7 | 7 | -include("elixir.hrl").
|
8 | 8 |
|
| 9 | +-define(empty_map_set_pattern, {map, _, [ |
| 10 | + {map_field_assoc, _, {atom, _, '__struct__'}, {atom, _, 'Elixir.MapSet'}}, |
| 11 | + {map_field_assoc, _, {atom, _, map}, {map, _, []}} |
| 12 | + ]}). |
| 13 | + |
9 | 14 | translate(Meta, Args, S) ->
|
10 | 15 | {Cases, [{do, Expr} | Opts]} = elixir_utils:split_last(Args),
|
11 | 16 |
|
@@ -156,6 +161,10 @@ build_inline_each(Ann, Clauses, Expr, {bin, _, []}, Uniq, S) ->
|
156 | 161 | build_into(Ann, Clauses, Expr, {map, _, []}, Uniq, S) ->
|
157 | 162 | {ReduceExpr, SR} = build_inline_each(Ann, Clauses, Expr, {nil, Ann}, Uniq, S),
|
158 | 163 | {?remote(Ann, maps, from_list, [ReduceExpr]), SR};
|
| 164 | +build_into(Ann, Clauses, Expr, ?empty_map_set_pattern = _Into, Uniq, S) -> |
| 165 | + InnerFun = fun(InnerExpr, InnerAcc) -> {cons, Ann, InnerExpr, InnerAcc} end, |
| 166 | + {ReduceExpr, SR} = build_reduce(Ann, Clauses, InnerFun, Expr, {nil, Ann}, Uniq, S), |
| 167 | + {?remote(Ann, 'Elixir.MapSet', new, [ReduceExpr]), SR}; |
159 | 168 | build_into(Ann, Clauses, Expr, Into, Uniq, S) ->
|
160 | 169 | {Fun, SF} = build_var(Ann, S),
|
161 | 170 | {Acc, SA} = build_var(Ann, SF),
|
|
0 commit comments