aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2016-09-05 11:43:38 +0200
committerBjörn Gustavsson <[email protected]>2016-09-05 11:43:38 +0200
commitb501396623e80a798fba94a428646461aabe6796 (patch)
treed426e3b61718b3e641553cd70157c986b99e5251 /lib/compiler/src
parent727f08889ab2096b540d466858ded1271bf261a8 (diff)
parent0baa07cdf2754748bbc2d969bf83f08c0976fb78 (diff)
downloadotp-b501396623e80a798fba94a428646461aabe6796.tar.gz
otp-b501396623e80a798fba94a428646461aabe6796.tar.bz2
otp-b501396623e80a798fba94a428646461aabe6796.zip
Merge branch 'bjorn/lc-overridden-bif/OTP-13690'
* bjorn/lc-overridden-bif/OTP-13690: Fix overridden BIFs Don't crash when obsolete guard overrides local function
Diffstat (limited to 'lib/compiler/src')
-rw-r--r--lib/compiler/src/v3_core.erl17
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/compiler/src/v3_core.erl b/lib/compiler/src/v3_core.erl
index 0f80eb68fa..b96d3df8fe 100644
--- a/lib/compiler/src/v3_core.erl
+++ b/lib/compiler/src/v3_core.erl
@@ -1640,10 +1640,19 @@ get_unit({bin_element,_,_,_,Flags}) ->
U.
%% is_guard_test(Expression) -> true | false.
-%% Test if a general expression is a guard test. Use erl_lint here
-%% as it now allows sys_pre_expand transformed source.
-
-is_guard_test(E) -> erl_lint:is_guard_test(E).
+%% Test if a general expression is a guard test.
+%%
+%% Note that a local function overrides a BIF with the same name.
+%% For example, if there is a local function named is_list/1,
+%% any unqualified call to is_list/1 will be to the local function.
+%% The guard function must be explicitly called as erlang:is_list/1.
+
+is_guard_test(E) ->
+ %% erl_expand_records has added a module prefix to any call
+ %% to a BIF or imported function. Any call without a module
+ %% prefix that remains must therefore be to a local function.
+ IsOverridden = fun({_,_}) -> true end,
+ erl_lint:is_guard_test(E, [], IsOverridden).
%% novars(Expr, State) -> {Novars,[PreExpr],State}.
%% Generate a novars expression, basically a call or a safe. At this