From 7db359b7a1d9b33b25750b29c92c6074ab415c45 Mon Sep 17 00:00:00 2001 From: Hans Bolinder Date: Mon, 10 Sep 2018 12:20:57 +0200 Subject: syntax_tools: Correct unfolding of the stacktrace variable The bug was introduced in 9ab233. See also https://bugs.erlang.org/browse/ERL-719. --- lib/syntax_tools/src/erl_syntax.erl | 2 +- lib/syntax_tools/test/merl_SUITE.erl | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/syntax_tools/src/erl_syntax.erl b/lib/syntax_tools/src/erl_syntax.erl index 758aff32fd..331081a07e 100644 --- a/lib/syntax_tools/src/erl_syntax.erl +++ b/lib/syntax_tools/src/erl_syntax.erl @@ -3897,7 +3897,7 @@ unfold_try_clauses(Cs) -> unfold_try_clause({clause, Pos, [{tuple, _, [{atom, _, throw}, V, - [{var, _, '_'}]]}], + {var, _, '_'}]}], Guard, Body}) -> {clause, Pos, [V], Guard, Body}; unfold_try_clause({clause, Pos, [{tuple, _, [C, V, Stacktrace]}], diff --git a/lib/syntax_tools/test/merl_SUITE.erl b/lib/syntax_tools/test/merl_SUITE.erl index 52bbd9b3b8..6389ad7738 100644 --- a/lib/syntax_tools/test/merl_SUITE.erl +++ b/lib/syntax_tools/test/merl_SUITE.erl @@ -30,13 +30,14 @@ %% Test cases -export([merl_smoke_test/1, - transform_parse_error_test/1]). + transform_parse_error_test/1, otp_15291/1]). suite() -> [{ct_hooks,[ts_install_cth]}]. all() -> [merl_smoke_test, - transform_parse_error_test]. + transform_parse_error_test, + otp_15291]. groups() -> []. @@ -101,6 +102,15 @@ transform_parse_error_test(_Config) -> [?Q("merl:qquote(2, \"{\", [{var, V}])")], []))), ok. +otp_15291(_Config) -> + C0 = merl:quote("() -> ok"), + {clause,1,[],[],[{atom,1,ok}]} = C0, + C2 = merl:quote("(_,_) -> ok"), + {clause,1,[{var,1,'_'},{var,1,'_'}],[],[{atom,1,ok}]} = C2, + C1 = merl:quote("(_) -> ok"), + {clause,1,[{var,1,'_'}],[],[{atom,1,ok}]} = C1, + ok. + %% utilities f(Ts) when is_list(Ts) -> -- cgit v1.2.3