diff options
author | Hans Bolinder <[email protected]> | 2019-04-08 11:36:41 +0200 |
---|---|---|
committer | Hans Bolinder <[email protected]> | 2019-04-08 11:36:41 +0200 |
commit | 0682f0a9b141090caee750bfc34a424a2e0defa2 (patch) | |
tree | ddf349a998a51af808e406959792d5d00795161a /lib | |
parent | 6bab8b623ad5352ee5532e3b1864185e976e31d6 (diff) | |
download | otp-0682f0a9b141090caee750bfc34a424a2e0defa2.tar.gz otp-0682f0a9b141090caee750bfc34a424a2e0defa2.tar.bz2 otp-0682f0a9b141090caee750bfc34a424a2e0defa2.zip |
stdlib: Fix a bug concerning exception class 'throw'
Since the introduction of the stack trace variable, the Erlang Pretty
Printer has left out the exception class 'throw' even when the stack
trace variable cannot be left out, which is not correct Erlang code.
The fix is to always include the exception class 'throw'.
An alternative is to exclude 'throw' exactly when the stack trace
variable is '_'.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/stdlib/src/erl_pp.erl | 6 | ||||
-rw-r--r-- | lib/stdlib/test/erl_pp_SUITE.erl | 37 |
2 files changed, 35 insertions, 8 deletions
diff --git a/lib/stdlib/src/erl_pp.erl b/lib/stdlib/src/erl_pp.erl index ada3ff5de3..3e68c1b225 100644 --- a/lib/stdlib/src/erl_pp.erl +++ b/lib/stdlib/src/erl_pp.erl @@ -808,12 +808,6 @@ cr_clause({clause,_,[T],G,B}, Opts) -> try_clauses(Cs, Opts) -> clauses(fun try_clause/2, Opts, Cs). -try_clause({clause,_,[{tuple,_,[{atom,_,throw},V,S]}],G,B}, Opts) -> - El = lexpr(V, 0, Opts), - Sl = stack_backtrace(S, [El], Opts), - Gl = guard_when(Sl, G, Opts), - Bl = body(B, Opts), - {step,Gl,Bl}; try_clause({clause,_,[{tuple,_,[C,V,S]}],G,B}, Opts) -> Cs = lexpr(C, 0, Opts), El = lexpr(V, 0, Opts), diff --git a/lib/stdlib/test/erl_pp_SUITE.erl b/lib/stdlib/test/erl_pp_SUITE.erl index f5d80e7e68..e5d1910070 100644 --- a/lib/stdlib/test/erl_pp_SUITE.erl +++ b/lib/stdlib/test/erl_pp_SUITE.erl @@ -51,7 +51,7 @@ otp_6321/1, otp_6911/1, otp_6914/1, otp_8150/1, otp_8238/1, otp_8473/1, otp_8522/1, otp_8567/1, otp_8664/1, otp_9147/1, otp_10302/1, otp_10820/1, otp_11100/1, otp_11861/1, pr_1014/1, - otp_13662/1, otp_14285/1, otp_15592/1]). + otp_13662/1, otp_14285/1, otp_15592/1, otp_15751/1]). %% Internal export. -export([ehook/6]). @@ -81,7 +81,7 @@ groups() -> [otp_6321, otp_6911, otp_6914, otp_8150, otp_8238, otp_8473, otp_8522, otp_8567, otp_8664, otp_9147, otp_10302, otp_10820, otp_11100, otp_11861, pr_1014, otp_13662, - otp_14285, otp_15592]}]. + otp_14285, otp_15592, otp_15751]}]. init_per_suite(Config) -> Config. @@ -1172,6 +1172,39 @@ otp_15592(_Config) -> "56789012345678901234:f(<<>>)">>), ok. +otp_15751(_Config) -> + ok = pp_expr(<<"try foo:bar() + catch + Reason : Stacktrace -> + {Reason, Stacktrace} + end">>), + ok = pp_expr(<<"try foo:bar() + catch + throw: Reason : Stacktrace -> + {Reason, Stacktrace} + end">>), + ok = pp_expr(<<"try foo:bar() + catch + Reason : _ -> + Reason + end">>), + ok = pp_expr(<<"try foo:bar() + catch + throw: Reason : _ -> + Reason + end">>), + ok = pp_expr(<<"try foo:bar() + catch + Reason -> + Reason + end">>), + ok = pp_expr(<<"try foo:bar() + catch + throw: Reason -> + Reason + end">>), + ok. + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% compile(Config, Tests) -> |