Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:20
erlang
0794-fun2ms-accept-in-function-head-when-called...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0794-fun2ms-accept-in-function-head-when-called-from-shel.patch of Package erlang
From a69d7ba56ad1f0983c6aea7538742d2a1c4e1d7a Mon Sep 17 00:00:00 2001 From: Magnus Henoch <magnus.henoch@gmail.com> Date: Fri, 12 Jul 2019 14:38:05 +0100 Subject: [PATCH] fun2ms: accept ++ in function head when called from shell Code such as ets:fun2ms(fun({"foo" ++ X}) -> X end) works fine in compiled code. Let's make it work when fun2ms is invoked from the shell as well. --- lib/stdlib/src/ms_transform.erl | 2 ++ lib/stdlib/test/ms_transform_SUITE.erl | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/lib/stdlib/src/ms_transform.erl b/lib/stdlib/src/ms_transform.erl index 97ec785c62..74efe5c513 100644 --- a/lib/stdlib/src/ms_transform.erl +++ b/lib/stdlib/src/ms_transform.erl @@ -1100,6 +1100,8 @@ normalise({bin,_,Fs}) -> B; normalise({cons,_,Head,Tail}) -> [normalise(Head)|normalise(Tail)]; +normalise({op,_,'++',A,B}) -> + normalise(A) ++ normalise(B); normalise({tuple,_,Args}) -> list_to_tuple(normalise_list(Args)); normalise({map,_,Pairs0}) -> diff --git a/lib/stdlib/test/ms_transform_SUITE.erl b/lib/stdlib/test/ms_transform_SUITE.erl index d1e6faf863..29423ed032 100644 --- a/lib/stdlib/test/ms_transform_SUITE.erl +++ b/lib/stdlib/test/ms_transform_SUITE.erl @@ -281,6 +281,8 @@ basic_ets(Config) when is_list(Config) -> compile_and_run(<<"ets:fun2ms(fun({A,B}) -> {B,A} end)">>), [{{'$1','$2'},[],[['$2','$1']]}] = compile_and_run(<<"ets:fun2ms(fun({A,B}) -> [B,A] end)">>), + [{{"foo" ++ '_','$1'},[],['$1']}] = + compile_and_run(<<"ets:fun2ms(fun({\"foo\" ++ _, X}) -> X end)">>), ok. %% Tests basic ets:fun2ms. @@ -313,6 +315,8 @@ from_shell(Config) when is_list(Config) -> [{[a,b],[],[{message,banan},{return_trace}]}] = do_eval( "dbg:fun2ms(fun([a,b]) -> message(banan), return_trace() end)"), + [{{"foo" ++ '_','$1'},[],['$1']}] = + do_eval("ets:fun2ms(fun({\"foo\" ++ _, X}) -> X end)"), ok. %% Tests expansion of records in fun2ms. -- 2.16.4
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