Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
erlang
8071-Fix-minor-imparity-issues-between-various-...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 8071-Fix-minor-imparity-issues-between-various-generator-.patch of Package erlang
From 0f0e375d835bf83e3eae3f4b994634eaecdf8339 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Szoboszlay?= <dszoboszlay@gmail.com> Date: Thu, 13 Jun 2024 12:52:59 +0200 Subject: [PATCH 1/2] Fix minor imparity issues between various generator types --- lib/stdlib/src/erl_parse.yrl | 2 +- lib/stdlib/src/qlc_pt.erl | 5 +++- lib/stdlib/src/shell.erl | 2 ++ lib/syntax_tools/src/erl_syntax.erl | 8 +++--- lib/syntax_tools/src/erl_syntax_lib.erl | 26 +++++++++++++++----- lib/syntax_tools/test/syntax_tools_SUITE.erl | 2 ++ 6 files changed, 33 insertions(+), 12 deletions(-) diff --git a/lib/stdlib/doc/src/erl_parse.xml b/lib/stdlib/doc/src/erl_parse.xml index 01540c00db..dd99245d33 100644 --- a/lib/stdlib/doc/src/erl_parse.xml +++ b/lib/stdlib/doc/src/erl_parse.xml @@ -83,8 +83,7 @@ <datatype> <name>af_generator()</name> <desc> - <p>Abstract representation of a generator - or a bitstring generator.</p> + <p>Abstract representation of a list, bitstring or map generator.</p> </desc> </datatype> <datatype> diff --git a/lib/stdlib/src/qlc_pt.erl b/lib/stdlib/src/qlc_pt.erl index 21c55555ae..d34b139781 100644 --- a/lib/stdlib/src/qlc_pt.erl +++ b/lib/stdlib/src/qlc_pt.erl @@ -292,10 +292,13 @@ record_attributes(Forms) -> %% transformation. %% compile_messages(Forms, FormsNoShadows, Options, State) -> - %% The qlc module cannot handle binary generators. + %% The qlc module can only handle list generators. BGenF = fun(_QId,{b_generate,Anno,_P,_LE}=BGen, GA, A) -> M = {loc(Anno),?APIMOD,binary_generator}, {BGen,[{get(?QLC_FILE),[M]}|GA],A}; + (_QId,{m_generate,Anno,_P,_LE}=BGen, GA, A) -> + M = {loc(Anno),?APIMOD,map_generator}, + {BGen,[{get(?QLC_FILE),[M]}|GA],A}; (_QId, Q, GA, A) -> {Q,GA,A} end, diff --git a/lib/stdlib/src/shell.erl b/lib/stdlib/src/shell.erl index 002f0d1678..22a335c739 100644 --- a/lib/stdlib/src/shell.erl +++ b/lib/stdlib/src/shell.erl @@ -644,6 +644,8 @@ expand_quals([{generate,A,P,E}|Qs], C) -> [{generate,A,P,expand_expr(E, C)}|expand_quals(Qs, C)]; expand_quals([{b_generate,A,P,E}|Qs], C) -> [{b_generate,A,P,expand_expr(E, C)}|expand_quals(Qs, C)]; +expand_quals([{m_generate,A,P,E}|Qs], C) -> + [{m_generate,A,P,expand_expr(E, C)}|expand_quals(Qs, C)]; expand_quals([E|Qs], C) -> [expand_expr(E, C)|expand_quals(Qs, C)]; expand_quals([], _C) -> []. diff --git a/lib/syntax_tools/src/erl_syntax.erl b/lib/syntax_tools/src/erl_syntax.erl index a6fd397fda..84605345df 100644 --- a/lib/syntax_tools/src/erl_syntax.erl +++ b/lib/syntax_tools/src/erl_syntax.erl @@ -2650,7 +2650,7 @@ compact_list(Node) -> copy_attrs(Node, Node1)); _ -> - Node + Node end end; _ -> @@ -3172,7 +3172,7 @@ revert_attribute(Node) -> revert_attribute_1(module, [M], Pos, Node) -> case revert_module_name(M) of - {ok, A} -> + {ok, A} -> {attribute, Pos, module, A}; error -> Node end; @@ -3189,7 +3189,7 @@ revert_attribute_1(module, [M, List], Pos, Node) -> Node end, case revert_module_name(M) of - {ok, A} -> + {ok, A} -> {attribute, Pos, module, {A, Vs}}; error -> Node end; @@ -7528,7 +7528,7 @@ subtrees(T) -> Ts] end; binary_generator -> - [[binary_generator_pattern(T)], + [[binary_generator_pattern(T)], [binary_generator_body(T)]]; bitstring_type -> [[bitstring_type_m(T)], diff --git a/lib/syntax_tools/src/erl_syntax_lib.erl b/lib/syntax_tools/src/erl_syntax_lib.erl index 2e0df3c46b..8b0e1126d6 100644 --- a/lib/syntax_tools/src/erl_syntax_lib.erl +++ b/lib/syntax_tools/src/erl_syntax_lib.erl @@ -494,6 +494,8 @@ vann(Tree, Env) -> vann_generator(Tree, Env); binary_generator -> vann_binary_generator(Tree, Env); + map_generator -> + vann_map_generator(Tree, Env); block_expr -> vann_block_expr(Tree, Env); macro -> @@ -626,10 +628,12 @@ vann_list_comp(Tree, Env) -> vann_list_comp_body_join() -> fun (T, {Env, Bound, Free}) -> {T1, Bound1, Free1} = case erl_syntax:type(T) of - binary_generator -> - vann_binary_generator(T,Env); - generator -> + generator -> vann_generator(T, Env); + binary_generator -> + vann_binary_generator(T,Env); + map_generator -> + vann_map_generator(T,Env); _ -> %% Bindings in filters are not %% exported to the rest of the @@ -662,10 +666,12 @@ vann_binary_comp(Tree, Env) -> vann_binary_comp_body_join() -> fun (T, {Env, Bound, Free}) -> {T1, Bound1, Free1} = case erl_syntax:type(T) of - binary_generator -> - vann_binary_generator(T, Env); - generator -> + generator -> vann_generator(T, Env); + binary_generator -> + vann_binary_generator(T,Env); + map_generator -> + vann_map_generator(T,Env); _ -> %% Bindings in filters are not %% exported to the rest of the @@ -705,6 +711,14 @@ vann_binary_generator(Tree, Env) -> Tree1 = rewrite(Tree, erl_syntax:binary_generator(P1, E1)), {ann_bindings(Tree1, Env, Bound, Free), Bound, Free}. +vann_map_generator(Tree, Env) -> + P = erl_syntax:map_generator_pattern(Tree), + {P1, Bound, _} = vann_pattern(P, []), + E = erl_syntax:map_generator_body(Tree), + {E1, _, Free} = vann(E, Env), + Tree1 = rewrite(Tree, erl_syntax:map_generator(P1, E1)), + {ann_bindings(Tree1, Env, Bound, Free), Bound, Free}. + vann_block_expr(Tree, Env) -> Es = erl_syntax:block_expr_body(Tree), {Es1, {Bound, Free}} = vann_body(Es, Env), diff --git a/lib/syntax_tools/test/syntax_tools_SUITE.erl b/lib/syntax_tools/test/syntax_tools_SUITE.erl index 0ed660121f..bb6b361748 100644 --- a/lib/syntax_tools/test/syntax_tools_SUITE.erl +++ b/lib/syntax_tools/test/syntax_tools_SUITE.erl @@ -335,6 +335,8 @@ t_erl_parse_type(Config) when is_list(Config) -> {"[catch V||V <- Vs]", list_comp,false}, {"<< <<B>> || <<B>> <= Bs>>", binary_comp,false}, {"<< (catch <<B>>) || <<B>> <= Bs>>", binary_comp,false}, + {"#{K => V || {K,V} <- KVs}", map_comp,false}, + {"#{K => (catch V) || {K,V} <- KVs}", map_comp,false}, {"#state{ a = A, b = B}", record_expr,false}, {"#state{}", record_expr,false}, {"#s{ a = #def{ a=A }, b = B}", record_expr,false}, -- 2.43.0
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor