Skip to content

Commit

Permalink
fixup! compiler: Add zip generators for comprehensions
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorng committed Oct 10, 2024
1 parent 8ed2ca6 commit 8585320
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
12 changes: 3 additions & 9 deletions lib/debugger/src/dbg_ieval.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1236,15 +1236,9 @@ bind_all_generators1([{m_generate, Anno, P, Iter0}|Qs], Acc, Bs0, Ieval, continu
end;
bind_all_generators1([{m_generate, Anno, P, Iter0}|Qs], Acc, Bs0, Ieval, skip) ->
case maps:next(Iter0) of
{K,V,Iter} ->
case catch match1(P, {K,V}, erl_eval:new_bindings(Bs0), Bs0) of
{match,_} ->
bind_all_generators1(Qs, [{m_generate, Anno, P, Iter}|Acc],
Bs0, Ieval, skip);
nomatch ->
bind_all_generators1(Qs, [{m_generate, Anno, P, Iter}|Acc],
Bs0, Ieval, skip)
end;
{_K,_V,Iter} ->
bind_all_generators1(Qs, [{m_generate, Anno, P, Iter}|Acc],
Bs0, Ieval, skip);
none ->
{[], skip}
end;
Expand Down
10 changes: 10 additions & 0 deletions lib/debugger/test/zlc_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,16 @@ zmc(Config) when is_list(Config) ->
<< <<X:64, Y:64, Z:64, W:64>> || X := Y <- M3 && Z := W <- M4>>,
true = << <<(A*3):64>> || A <- Seq>> =:=
<< <<(X+Y+Z):64>> || X := Y <- M1 && Z <- Seq>>,

M5 = maps:iterator(#{X =>
case X rem 2 of
0 -> {ok,X};
1 -> {error,X}
end || X <- Seq}, ordered),
M6 = maps:iterator(#{X*2 => X*4 || X <- Seq}, ordered),
Result = [X || {{X,{ok,X}}, {_,X}} <- lists:zip(maps:to_list(M5), maps:to_list(M6))],
Result = [X || X := {ok,X} <- M5 && _ := X <- M6],

ok.

filter_guard(Config) when is_list(Config) ->
Expand Down

0 comments on commit 8585320

Please sign in to comment.