summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/compiler/src/erl_bifs.erl10
-rw-r--r--lib/compiler/test/fun_SUITE.erl7
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,