Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:19
erlang
2774-Don-t-eliminate-unused-erlang-make_fun3-3....
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 2774-Don-t-eliminate-unused-erlang-make_fun3-3.patch of Package erlang
From 43758a7511214b2547ee7b5de4f7bc05a2ca78f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org> Date: Mon, 12 Oct 2020 09:16:06 +0200 Subject: [PATCH 3/3] Don't eliminate unused erlang:make_fun3/3 `erlang:make_fun3/3` is not a safe BIF. The following function should fail: f() -> fun m:f/bad_arity, ok. --- lib/compiler/src/erl_bifs.erl | 10 +++++++--- lib/compiler/test/fun_SUITE.erl | 7 +++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/compiler/src/erl_bifs.erl b/lib/compiler/src/erl_bifs.erl index e0fa8502a1..567e7e8f42 100644 --- a/lib/compiler/src/erl_bifs.erl +++ b/lib/compiler/src/erl_bifs.erl @@ -188,8 +188,13 @@ is_pure(_, _, _) -> false. %% and does not affect the state (although the value it returns %% might depend on the state). %% -%% Note: is_function/2 and is_record/3 are NOT safe: is_function(X, foo) -%% and is_record(X, foo, bar) will fail. +%% NOTES +%% +%% is_function/2 is not safe: is_function(X, foo) will fail. +%% +%% is_record/3 is not safe: is_record(X, foo, bar) will fail. +%% +%% erlang:make_fun/3 is safe: erlang:make_fun3(foo, bar, baz) will fail. -spec is_safe(atom(), atom(), arity()) -> boolean(). @@ -223,7 +228,6 @@ is_safe(erlang, is_port, 1) -> true; is_safe(erlang, is_reference, 1) -> true; is_safe(erlang, is_tuple, 1) -> true; is_safe(erlang, make_ref, 0) -> true; -is_safe(erlang, make_fun, 3) -> true; is_safe(erlang, max, 2) -> true; is_safe(erlang, min, 2) -> true; is_safe(erlang, node, 0) -> true; diff --git a/lib/compiler/test/fun_SUITE.erl b/lib/compiler/test/fun_SUITE.erl index 3b8e8698de..bd8603ae81 100644 --- a/lib/compiler/test/fun_SUITE.erl +++ b/lib/compiler/test/fun_SUITE.erl @@ -206,11 +206,18 @@ external(Config) when is_list(Config) -> {'EXIT',{{badarity,_},_}} = (catch (id(fun lists:sum/1))(1, 2, 3)), {'EXIT',{{badarity,_},_}} = (catch apply(fun lists:sum/1, [1,2,3])), + {'EXIT',{badarg,_}} = (catch bad_external_fun()), + ok. call_me(I) -> {ok,I}. +bad_external_fun() -> + V0 = idea, + fun V0:V0/V0, %Should fail. + never_reached. + eep37(Config) when is_list(Config) -> F = fun Fact(N) when N > 0 -> N * Fact(N - 1); Fact(0) -> 1 end, Add = fun _(N) -> N + 1 end, -- 2.26.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor