aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAnthony Ramine <[email protected]>2013-01-11 17:08:08 +0100
committerAnthony Ramine <[email protected]>2013-01-16 15:07:52 +0100
commit25904f0e6ed034979c2686c6c08daf3ba231ebcc (patch)
tree3db83709ac20165eb50a5680b946ae86a5241f55 /lib
parent3e8a6c8bceea8552ef50bd8dcfc14a0f79c9f32e (diff)
downloadotp-25904f0e6ed034979c2686c6c08daf3ba231ebcc.tar.gz
otp-25904f0e6ed034979c2686c6c08daf3ba231ebcc.tar.bz2
otp-25904f0e6ed034979c2686c6c08daf3ba231ebcc.zip
Forbid local fun variables in Core Erlang guards
Local fun variables are disallowed in both Erlang and Core Erlang guards but core_lint doesn't detect this kind of error, making the compilation fail later in the BEAM assembly generation. A guard is added to only allow #c_var{} terms where the name is an atom or an integer, which is the type used by the inliner when introducing new variables.
Diffstat (limited to 'lib')
-rw-r--r--lib/compiler/src/core_lint.erl3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/compiler/src/core_lint.erl b/lib/compiler/src/core_lint.erl
index b513a8965c..21296a8b66 100644
--- a/lib/compiler/src/core_lint.erl
+++ b/lib/compiler/src/core_lint.erl
@@ -247,7 +247,8 @@ gbody(E, Def, Rt, St0) ->
false -> St1
end.
-gexpr(#c_var{name=N}, Def, _Rt, St) -> expr_var(N, Def, St);
+gexpr(#c_var{name=N}, Def, _Rt, St) when is_atom(N); is_integer(N) ->
+ expr_var(N, Def, St);
gexpr(#c_literal{}, _Def, _Rt, St) -> St;
gexpr(#c_cons{hd=H,tl=T}, Def, _Rt, St) ->
gexpr_list([H,T], Def, St);