From 42c1915ad31e4ff8ecfdfedecab35cc7ca4648ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 20 Jul 2012 16:09:43 +0200 Subject: [PATCH] Improve error message when calling local inside guards --- lib/elixir/src/elixir_translator.erl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/elixir/src/elixir_translator.erl b/lib/elixir/src/elixir_translator.erl index 3bcdac589c..e33846e1e4 100644 --- a/lib/elixir/src/elixir_translator.erl +++ b/lib/elixir/src/elixir_translator.erl @@ -442,7 +442,13 @@ translate_each({Atom, Line, Args} = Original, S) when is_atom(Atom) -> false -> case handle_partials(Line, Original, S) of error -> - Callback = fun() -> translate_local(Line, Atom, Args, S) end, + Callback = fun() -> + case S#elixir_scope.context of + guard -> syntax_error(Line, S#elixir_scope.file, + "cannot invoke local ~s/~B inside guard", [Atom, length(Args)]); + _ -> translate_local(Line, Atom, Args, S) + end + end, elixir_dispatch:dispatch_import(Line, Atom, Args, S, Callback); Else -> Else end;