Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
erlang
0538-named_fun_expr-annotate-bindings-fix.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0538-named_fun_expr-annotate-bindings-fix.patch of Package erlang
From 36091468c3e042a3cf4838af4bf8191de9f60e7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Min=C4=91ek?= <marko.mindek@invariant.hr> Date: Wed, 30 Nov 2022 13:23:45 +0100 Subject: [PATCH] named_fun_expr annotate bindings fix --- lib/syntax_tools/src/erl_syntax_lib.erl | 14 +++++++++ lib/syntax_tools/test/syntax_tools_SUITE.erl | 31 ++++++++++++++++++-- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/lib/syntax_tools/src/erl_syntax_lib.erl b/lib/syntax_tools/src/erl_syntax_lib.erl index 78c7ab9e46..14ce07b486 100644 --- a/lib/syntax_tools/src/erl_syntax_lib.erl +++ b/lib/syntax_tools/src/erl_syntax_lib.erl @@ -538,6 +538,8 @@ vann(Tree, Env) -> vann_function(Tree, Env); fun_expr -> vann_fun_expr(Tree, Env); + named_fun_expr -> + vann_named_fun_expr(Tree, Env); list_comp -> vann_list_comp(Tree, Env); binary_comp -> @@ -583,6 +585,18 @@ vann_fun_expr(Tree, Env) -> Bound = [], {ann_bindings(Tree1, Env, Bound, Free), Bound, Free}. +vann_named_fun_expr(Tree, Env) -> + N = erl_syntax:named_fun_expr_name(Tree), + NBound = [erl_syntax:variable_name(N)], + NFree = [], + N1 = ann_bindings(N, Env, NBound, NFree), + Env1 = ordsets:union(Env, NBound), + Cs = erl_syntax:named_fun_expr_clauses(Tree), + {Cs1, {_, Free}} = vann_clauses(Cs, Env1), + Tree1 = rewrite(Tree, erl_syntax:named_fun_expr(N1,Cs1)), + Bound = [], + {ann_bindings(Tree1, Env, Bound, Free), Bound, Free}. + vann_match_expr(Tree, Env) -> E = erl_syntax:match_expr_body(Tree), {E1, Bound1, Free1} = vann(E, Env), diff --git a/lib/syntax_tools/test/syntax_tools_SUITE.erl b/lib/syntax_tools/test/syntax_tools_SUITE.erl index 6d91ab8f54..3553f7a71f 100644 --- a/lib/syntax_tools/test/syntax_tools_SUITE.erl +++ b/lib/syntax_tools/test/syntax_tools_SUITE.erl @@ -27,7 +27,7 @@ revert_map_type/1,wrapped_subtrees/1, t_abstract_type/1,t_erl_parse_type/1,t_type/1, t_epp_dodger/1,t_epp_dodger_clever/1, - t_comment_scan/1,t_prettypr/1]). + t_comment_scan/1,t_prettypr/1,test_named_fun_bind_ann/1]). suite() -> [{ct_hooks,[ts_install_cth]}]. @@ -36,7 +36,7 @@ all() -> wrapped_subtrees, t_abstract_type,t_erl_parse_type,t_type, t_epp_dodger,t_epp_dodger_clever, - t_comment_scan,t_prettypr]. + t_comment_scan,t_prettypr,test_named_fun_bind_ann]. groups() -> []. @@ -355,6 +355,33 @@ t_prettypr(Config) when is_list(Config) -> ok = test_prettypr(Filenames,DataDir,PrivDir), ok. +%% Test bug (#4733) fix for annotating bindings for named fun expressions +test_named_fun_bind_ann(Config) when is_list(Config) -> + Fn = {named_fun,{6,5}, + 'F', + [{clause,{6,9}, + [{var,{6,11},'Test'}], + [], + [{var,{7,13},'Test'}]}]}, + AnnT = erl_syntax_lib:annotate_bindings(Fn, []), + [Env, Bound, Free] = erl_syntax:get_ann(AnnT), + {'env',[]} = Env, + {'bound',[]} = Bound, + {'free',[]} = Free, + + NameVar = erl_syntax:named_fun_expr_name(AnnT), + Name = erl_syntax:variable_name(NameVar), + [NEnv, NBound, NFree] = erl_syntax:get_ann(NameVar), + {'env',[]} = NEnv, + {'bound',[Name]} = NBound, + {'free',[]} = NFree, + + [Clause] = erl_syntax:named_fun_expr_clauses(AnnT), + [CEnv, CBound, CFree] = erl_syntax:get_ann(Clause), + {'env',[Name]} = CEnv, + {'bound',['Test']} = CBound, + {'free', []} = CFree. + test_files(Config) -> DataDir = ?config(data_dir, Config), [ filename:join(DataDir,Filename) || Filename <- test_files() ]. -- 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