aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2018-11-21 10:23:36 +0100
committerBjörn Gustavsson <[email protected]>2018-11-21 10:23:36 +0100
commite83c98c7ca43ea00923660b8fcdf6bd49a9f5405 (patch)
treeb9f95bfd1c69a3236d86d136a5737c820b8af2b0 /lib/compiler
parentee3c9d55b2a483df5a4650ab6e3ef2bbf6b0b090 (diff)
parentf8183c3949b3da11fafac4e5b7737fb75e0d0f11 (diff)
downloadotp-e83c98c7ca43ea00923660b8fcdf6bd49a9f5405.tar.gz
otp-e83c98c7ca43ea00923660b8fcdf6bd49a9f5405.tar.bz2
otp-e83c98c7ca43ea00923660b8fcdf6bd49a9f5405.zip
Merge branch 'maint'
* maint: Fix internal consistency failure for is_function/2 Conflicts: lib/compiler/src/beam_utils.erl
Diffstat (limited to 'lib/compiler')
-rw-r--r--lib/compiler/test/beam_utils_SUITE.erl23
1 files changed, 21 insertions, 2 deletions
diff --git a/lib/compiler/test/beam_utils_SUITE.erl b/lib/compiler/test/beam_utils_SUITE.erl
index ac19305d69..ff0f72d519 100644
--- a/lib/compiler/test/beam_utils_SUITE.erl
+++ b/lib/compiler/test/beam_utils_SUITE.erl
@@ -26,7 +26,7 @@
select/1,y_catch/1,otp_8949_b/1,liveopt/1,coverage/1,
y_registers/1,user_predef/1,scan_f/1,cafu/1,
receive_label/1,read_size_file_version/1,not_used/1,
- is_used_fr/1]).
+ is_used_fr/1,unsafe_is_function/1]).
-export([id/1]).
suite() -> [{ct_hooks,[ts_install_cth]}].
@@ -53,7 +53,8 @@ groups() ->
cafu,
read_size_file_version,
not_used,
- is_used_fr
+ is_used_fr,
+ unsafe_is_function
]}].
init_per_suite(Config) ->
@@ -570,6 +571,24 @@ is_used_fr(X, Y) ->
end,
X ! 1.
+%% ERL-778.
+unsafe_is_function(Config) ->
+ {undefined,any} = unsafe_is_function(undefined, any),
+ {ok,any} = unsafe_is_function(fun() -> ok end, any),
+ {'EXIT',{{case_clause,_},_}} = (catch unsafe_is_function(fun(_) -> ok end, any)),
+ ok.
+
+unsafe_is_function(F, M) ->
+ %% There would be an internal consistency failure:
+ %% Instruction: {bif,is_function,{f,0},[{x,0},{integer,0}],{x,2}}
+ %% Error: {uninitialized_reg,{y,0}}:
+
+ NewValue = case is_function(F, 0) of
+ true -> F();
+ false when F =:= undefined -> undefined
+ end,
+ {NewValue,M}.
+
%% The identity function.
id(I) -> I.