File 3481-stdlib-Correct-the-Erlang-parser-s-precedence-of-cat.patch of Package erlang
From 762a18aa2db089506c1af6b9c72943e221b499cd Mon Sep 17 00:00:00 2001
From: Hans Bolinder <hasse@erlang.org>
Date: Wed, 21 Apr 2021 08:47:39 +0200
Subject: [PATCH] stdlib: Correct the Erlang parser's precedence of 'catch'
Correction of commit 3171f2b7.
---
lib/stdlib/src/erl_parse.yrl | 6 +++---
lib/stdlib/test/erl_pp_SUITE.erl | 1 +
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/lib/stdlib/src/erl_parse.yrl b/lib/stdlib/src/erl_parse.yrl
index 3c97d6d8cd..c874f17fe8 100644
--- a/lib/stdlib/src/erl_parse.yrl
+++ b/lib/stdlib/src/erl_parse.yrl
@@ -1617,7 +1617,7 @@ inop_prec('.') -> {900,900,1000}.
-spec preop_prec(pre_op()) -> {0 | 600 | 700, 100 | 700 | 800}.
-preop_prec('catch') -> {950,100};
+preop_prec('catch') -> {700,100};
preop_prec('+') -> {600,700};
preop_prec('-') -> {600,700};
preop_prec('bnot') -> {600,700};
@@ -1628,9 +1628,9 @@ preop_prec('#') -> {700,800}.
func_prec() -> {800,700}.
--spec max_prec() -> 1000.
+-spec max_prec() -> 900.
-max_prec() -> 1000.
+max_prec() -> 900.
-type prec() :: non_neg_integer().
diff --git a/lib/stdlib/test/erl_pp_SUITE.erl b/lib/stdlib/test/erl_pp_SUITE.erl
index 8e4feb69f3..ad49321aaa 100644
--- a/lib/stdlib/test/erl_pp_SUITE.erl
+++ b/lib/stdlib/test/erl_pp_SUITE.erl
@@ -1309,6 +1309,7 @@ otp_16435(_Config) ->
CheckF("f() ->\n catch 1 = catch 1.\n"),
CheckF("f() ->\n A = catch 1 / 0.\n"),
CheckF("f() when erlang:float(3.0) ->\n true.\n"),
+ CheckF("f() ->\n (catch 16)#{}.\n"),
Check = fun(S) -> S = flat_parse_and_pp_expr(S, 0, []) end,
Check("5 #r4.f1"),
--
2.26.2