File 0165-core_lint-Allow-calls-to-erlang-error-1-in-guards.patch of Package erlang
From 866fe1e31ab88d28cfc71fcad65a24893c0d763a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Fri, 21 Feb 2020 16:13:26 +0100
Subject: [PATCH 02/30] core_lint: Allow calls to erlang:error/1 in guards
---
lib/compiler/src/core_lint.erl | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/lib/compiler/src/core_lint.erl b/lib/compiler/src/core_lint.erl
index 579fa59487..f3fe901949 100644
--- a/lib/compiler/src/core_lint.erl
+++ b/lib/compiler/src/core_lint.erl
@@ -277,11 +277,17 @@ gexpr(#c_call{module=#c_literal{val=erlang},name=#c_literal{val=is_record}},
gexpr(#c_call{module=#c_literal{val=erlang},name=#c_literal{val=Name},args=As},
Def, Rt, St0) when is_atom(Name) ->
St1 = return_match(Rt, 1, St0),
- case is_guard_bif(Name, length(As)) of
+ Arity = length(As),
+ case is_guard_bif(Name, Arity) of
true ->
gexpr_list(As, Def, St1);
false ->
- add_error({illegal_guard,St1#lint.func}, St1)
+ case {Name,Arity} of
+ {error,1} ->
+ gexpr_list(As, Def, St1);
+ _ ->
+ add_error({illegal_guard,St1#lint.func}, St1)
+ end
end;
gexpr(#c_primop{name=#c_literal{val=A},args=As}, Def, _Rt, St0) when is_atom(A) ->
gexpr_list(As, Def, St0);
--
2.16.4