diff options
author | Hans Bolinder <[email protected]> | 2017-01-12 15:34:53 +0100 |
---|---|---|
committer | Hans Bolinder <[email protected]> | 2017-01-12 15:34:53 +0100 |
commit | a2c5a9252ea2dd8382238ea4ec4e0850f4a15167 (patch) | |
tree | 6da4a938e4359f9bbfd9858f63fee003ce1c99af | |
parent | f7908744445a9cd66522f5201846fa3cdb3f2e3d (diff) | |
parent | 712e7beec6b1192d5e7294a166a81a3561a39595 (diff) | |
download | otp-a2c5a9252ea2dd8382238ea4ec4e0850f4a15167.tar.gz otp-a2c5a9252ea2dd8382238ea4ec4e0850f4a15167.tar.bz2 otp-a2c5a9252ea2dd8382238ea4ec4e0850f4a15167.zip |
Merge branch 'hasse/stdlib/fix_anno_types/OTP-14131' into maint
* hasse/stdlib/fix_anno_types/OTP-14131:
stdlib: Correct signatures of functions in erl_parse
-rw-r--r-- | lib/dialyzer/test/small_SUITE_data/src/anno.erl | 18 | ||||
-rw-r--r-- | lib/stdlib/src/erl_parse.yrl | 10 |
2 files changed, 25 insertions, 3 deletions
diff --git a/lib/dialyzer/test/small_SUITE_data/src/anno.erl b/lib/dialyzer/test/small_SUITE_data/src/anno.erl new file mode 100644 index 0000000000..70f1d42141 --- /dev/null +++ b/lib/dialyzer/test/small_SUITE_data/src/anno.erl @@ -0,0 +1,18 @@ +-module(anno). + +%% OTP-14131 + +-export([t1/0, t2/0, t3/0]). + +t1() -> + A = erl_parse:anno_from_term({attribute, 1, module, my_test}), + compile:forms([A], []). + +t2() -> + A = erl_parse:new_anno({attribute, 1, module, my_test}), + compile:forms([A], []). + +t3() -> + A = erl_parse:new_anno({attribute, 1, module, my_test}), + T = erl_parse:anno_to_term(A), + {attribute, 1, module, my_test} = T. diff --git a/lib/stdlib/src/erl_parse.yrl b/lib/stdlib/src/erl_parse.yrl index 5656155c53..d2dd2848b5 100644 --- a/lib/stdlib/src/erl_parse.yrl +++ b/lib/stdlib/src/erl_parse.yrl @@ -2,7 +2,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2016. All Rights Reserved. +%% Copyright Ericsson AB 1996-2017. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -1558,13 +1558,17 @@ new_anno(Term) -> Abstr :: erl_parse_tree(). anno_to_term(Abstract) -> - map_anno(fun erl_anno:to_term/1, Abstract). + F = fun(Anno, Acc) -> {erl_anno:to_term(Anno), Acc} end, + {NewAbstract, []} = modify_anno1(Abstract, [], F), + NewAbstract. -spec anno_from_term(Term) -> erl_parse_tree() when Term :: term(). anno_from_term(Term) -> - map_anno(fun erl_anno:from_term/1, Term). + F = fun(T, Acc) -> {erl_anno:from_term(T), Acc} end, + {NewTerm, []} = modify_anno1(Term, [], F), + NewTerm. %% Forms. %% Recognize what sys_pre_expand does: |