diff options
author | Erlang/OTP <[email protected]> | 2018-08-09 16:46:31 +0200 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2018-08-09 16:46:31 +0200 |
commit | f3fcc5908c860f92dcfe9a3da44f6d87605daaaa (patch) | |
tree | a0a2782658c14aaa98d20a2bb2961f7bb00a98b1 | |
parent | 0acdc8658ebf024885cc407b1bd1b3bd18c9cd36 (diff) | |
parent | f2e64e2a664691dd756dcc0d4583a40211828f3d (diff) | |
download | otp-f3fcc5908c860f92dcfe9a3da44f6d87605daaaa.tar.gz otp-f3fcc5908c860f92dcfe9a3da44f6d87605daaaa.tar.bz2 otp-f3fcc5908c860f92dcfe9a3da44f6d87605daaaa.zip |
Merge branch 'hasse/syntax_tools/fix_map_type/OTP-15098/ERIERL-177' into maint-19
* hasse/syntax_tools/fix_map_type/OTP-15098/ERIERL-177:
syntax_tools: Fix a bug regarding reverting map types.
-rw-r--r-- | lib/syntax_tools/src/erl_syntax.erl | 4 | ||||
-rw-r--r-- | lib/syntax_tools/test/syntax_tools_SUITE.erl | 24 |
2 files changed, 24 insertions, 4 deletions
diff --git a/lib/syntax_tools/src/erl_syntax.erl b/lib/syntax_tools/src/erl_syntax.erl index b856a5d1dd..91da3ad571 100644 --- a/lib/syntax_tools/src/erl_syntax.erl +++ b/lib/syntax_tools/src/erl_syntax.erl @@ -5300,7 +5300,7 @@ revert_map_type_assoc(Node) -> Pos = get_pos(Node), Name = map_type_assoc_name(Node), Value = map_type_assoc_value(Node), - {type, Pos, map_type_assoc, [Name, Value]}. + {type, Pos, map_field_assoc, [Name, Value]}. %% ===================================================================== @@ -5358,7 +5358,7 @@ revert_map_type_exact(Node) -> Pos = get_pos(Node), Name = map_type_exact_name(Node), Value = map_type_exact_value(Node), - {type, Pos, map_type_exact, [Name, Value]}. + {type, Pos, map_field_exact, [Name, Value]}. %% ===================================================================== diff --git a/lib/syntax_tools/test/syntax_tools_SUITE.erl b/lib/syntax_tools/test/syntax_tools_SUITE.erl index 43c17e9f1f..b03d249a60 100644 --- a/lib/syntax_tools/test/syntax_tools_SUITE.erl +++ b/lib/syntax_tools/test/syntax_tools_SUITE.erl @@ -26,13 +26,14 @@ %% Test cases -export([app_test/1,appup_test/1,smoke_test/1,revert/1,revert_map/1, + revert_map_type/1, t_abstract_type/1,t_erl_parse_type/1,t_epp_dodger/1, t_comment_scan/1,t_igor/1,t_erl_tidy/1]). suite() -> [{ct_hooks,[ts_install_cth]}]. all() -> - [app_test,appup_test,smoke_test,revert,revert_map, + [app_test,appup_test,smoke_test,revert,revert_map,revert_map_type, t_abstract_type,t_erl_parse_type,t_epp_dodger, t_comment_scan,t_igor,t_erl_tidy]. @@ -123,7 +124,26 @@ revert_map(Config) when is_list(Config) -> {map_field_assoc,{atom,17,name},{var,18,'Value'}}}]), ?t:timetrap_cancel(Dog). - +%% Testing bug fix for reverting map_field_assoc in types +revert_map_type(Config) when is_list(Config) -> + Dog = ?t:timetrap(?t:minutes(1)), + Form1 = {attribute,4,record, + {state, + [{typed_record_field, + {record_field,5,{atom,5,x}}, + {type,5,map, + [{type,5,map_field_exact,[{atom,5,y},{atom,5,z}]}]}}]}}, + Mapped1 = erl_syntax_lib:map(fun(X) -> X end, Form1), + Form1 = erl_syntax:revert(Mapped1), + Form2 = {attribute,4,record, + {state, + [{typed_record_field, + {record_field,5,{atom,5,x}}, + {type,5,map, + [{type,5,map_field_assoc,[{atom,5,y},{atom,5,z}]}]}}]}}, + Mapped2 = erl_syntax_lib:map(fun(X) -> X end, Form2), + Form2 = erl_syntax:revert(Mapped2), + ?t:timetrap_cancel(Dog). %% api tests |