diff options
author | Björn Gustavsson <[email protected]> | 2012-01-25 11:39:26 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2012-01-26 10:26:05 +0100 |
commit | 09d19b4e5e5314d6fc4ee04bc09a673ac8e0bd27 (patch) | |
tree | 1ac5c4d238a5697d8ee7c870d42616be91c63293 /lib/stdlib/src | |
parent | 23ec68ef0f06710733cdfba5fdeaea1d1df789cf (diff) | |
download | otp-09d19b4e5e5314d6fc4ee04bc09a673ac8e0bd27.tar.gz otp-09d19b4e5e5314d6fc4ee04bc09a673ac8e0bd27.tar.bz2 otp-09d19b4e5e5314d6fc4ee04bc09a673ac8e0bd27.zip |
erl_lint: Disallow call to is_record/3 if there is a local is_record/3
Attempting to call is_record/3 (without an erlang: prefix) from a
guard if there was a local function named is_record/3 would cause
a compiler crash. For consistency with other guard tests, disallow
the call.
is_record/2 in a guard will still be allowed (and work correctly)
even if there is a local is_record/2. It could be argued that
is_record/2 should be handled in the same way as is_record/3,
but changing that now could break working code.
Diffstat (limited to 'lib/stdlib/src')
-rw-r--r-- | lib/stdlib/src/erl_lint.erl | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/stdlib/src/erl_lint.erl b/lib/stdlib/src/erl_lint.erl index 2f29954dc9..cfbcf54d95 100644 --- a/lib/stdlib/src/erl_lint.erl +++ b/lib/stdlib/src/erl_lint.erl @@ -1808,7 +1808,7 @@ guard_test2({call,Line,{atom,_La,F},As}=G, Vt, St0) -> {Asvt,St1} = gexpr_list(As, Vt, St0), %Always check this. A = length(As), case erl_internal:type_test(F, A) of - true when F =/= is_record -> + true when F =/= is_record, A =/= 2 -> case no_guard_bif_clash(St1, {F,A}) of false -> {Asvt,add_error(Line, {illegal_guard_local_call,{F,A}}, St1)}; @@ -1872,9 +1872,15 @@ gexpr({call,Line,{atom,_Lr,is_record},[E,R]}, Vt, St0) -> gexpr({call,Line,{remote,_Lr,{atom,_Lm,erlang},{atom,Lf,is_record}},[E,A]}, Vt, St0) -> gexpr({call,Line,{atom,Lf,is_record},[E,A]}, Vt, St0); -gexpr({call,_Line,{atom,_Lr,is_record},[E,{atom,_,_Name},{integer,_,_}]}, +gexpr({call,Line,{atom,_Lr,is_record},[E0,{atom,_,_Name},{integer,_,_}]}, Vt, St0) -> - gexpr(E, Vt, St0); + {E,St1} = gexpr(E0, Vt, St0), + case no_guard_bif_clash(St0, {is_record,3}) of + true -> + {E,St1}; + false -> + {E,add_error(Line, {illegal_guard_local_call,{is_record,3}}, St1)} + end; gexpr({call,Line,{atom,_Lr,is_record},[_,_,_]=Asvt0}, Vt, St0) -> {Asvt,St1} = gexpr_list(Asvt0, Vt, St0), {Asvt,add_error(Line, illegal_guard_expr, St1)}; |