Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
erlang
5603-erl_lint-Handle-map-comprehensions.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 5603-erl_lint-Handle-map-comprehensions.patch of Package erlang
From 119d9a2ef1564deed244b7e5fe745f04b353ecb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org> Date: Tue, 17 Jan 2023 08:25:30 +0100 Subject: [PATCH 03/12] erl_lint: Handle map comprehensions --- lib/stdlib/src/erl_lint.erl | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/stdlib/src/erl_lint.erl b/lib/stdlib/src/erl_lint.erl index f7112ee008..b89f7cfc43 100644 --- a/lib/stdlib/src/erl_lint.erl +++ b/lib/stdlib/src/erl_lint.erl @@ -2348,6 +2348,8 @@ expr({lc,_Anno,E,Qs}, Vt, St) -> handle_comprehension(E, Qs, Vt, St); expr({bc,_Anno,E,Qs}, Vt, St) -> handle_comprehension(E, Qs, Vt, St); +expr({mc,_Anno,E,Qs}, Vt, St) -> + handle_comprehension(E, Qs, Vt, St); expr({tuple,_Anno,Es}, Vt, St) -> expr_list(Es, Vt, St); expr({map,_Anno,Es}, Vt, St) -> @@ -3544,7 +3546,7 @@ icrt_export([], _, _, _, Acc) -> handle_comprehension(E, Qs, Vt0, St0) -> {Vt1, Uvt, St1} = lc_quals(Qs, Vt0, St0), - {Evt,St2} = expr(E, Vt1, St1), + {Evt,St2} = comprehension_expr(E, Vt1, St1), Vt2 = vtupdate(Evt, Vt1), %% Shadowed global variables. {_,St3} = check_old_unused_vars(Vt2, Uvt, St2), @@ -3561,6 +3563,11 @@ handle_comprehension(E, Qs, Vt0, St0) -> Vt = vt_no_unsafe(vt_no_unused(Vt4)), {Vt, St}. +comprehension_expr({map_field_assoc,_,K,V}, Vt0, St0) -> + expr_list([K,V], Vt0, St0); +comprehension_expr(E, Vt, St) -> + expr(E, Vt, St). + %% lc_quals(Qualifiers, ImportVarTable, State) -> %% {VarTable,ShadowedVarTable,State} %% Test list comprehension qualifiers, return all variables. Allow @@ -3584,6 +3591,9 @@ lc_quals([{b_generate,_Anno,P,E} | Qs], Vt0, Uvt0, St0) -> St1 = handle_bitstring_gen_pat(P,St0), {Vt,Uvt,St} = handle_generator(P,E,Vt0,Uvt0,St1), lc_quals(Qs, Vt, Uvt, St); +lc_quals([{m_generate,_Anno,P,E} | Qs], Vt0, Uvt0, St0) -> + {Vt,Uvt,St} = handle_generator(P,E,Vt0,Uvt0,St0), + lc_quals(Qs, Vt, Uvt, St); lc_quals([F|Qs], Vt, Uvt, St0) -> Info = is_guard_test2_info(St0), {Fvt,St1} = case is_guard_test2(F, Info) of @@ -3605,7 +3615,7 @@ handle_generator(P,E,Vt,Uvt,St0) -> %% Forget variables local to E immediately. Vt1 = vtupdate(vtold(Evt, Vt), Vt), {_, St2} = check_unused_vars(Evt, Vt, St1), - {Pvt,Pnew,St3} = pattern(P, Vt1, [], St2), + {Pvt,Pnew,St3} = comprehension_pattern(P, Vt1, St2), %% Have to keep fresh variables separated from used variables somehow %% in order to handle for example X = foo(), [X || <<X:X>> <- bar()]. %% 1 2 2 1 @@ -3617,6 +3627,11 @@ handle_generator(P,E,Vt,Uvt,St0) -> Vt3 = vtupdate(vtsubtract(Vt2, Pnew), Pnew), {Vt3,NUvt,St5}. +comprehension_pattern({map_field_exact,_,K,V}, Vt, St) -> + pattern_list([K,V], Vt, [], St); +comprehension_pattern(P, Vt, St) -> + pattern(P, Vt, [], St). + handle_bitstring_gen_pat({bin,_,Segments=[_|_]},St) -> case lists:last(Segments) of {bin_element,Anno,_,default,Flags} when is_list(Flags) -> -- 2.35.3
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