Skip to content

Commit bf1da40

Browse files
author
José Valim
committed
Raise proper error on invalid function in quoted expressions, closes #2020
1 parent 9994dba commit bf1da40

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/elixir/src/elixir_exp.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ expand_many(Args, E) ->
396396
%% 3
397397
%%
398398
%% However, lexical information is.
399-
expand_arg(Arg, Acc) when is_number(Arg); is_atom(Arg); is_binary(Arg); is_pid(Arg); is_function(Arg) ->
399+
expand_arg(Arg, Acc) when is_number(Arg); is_atom(Arg); is_binary(Arg); is_pid(Arg) ->
400400
{ Arg, Acc };
401401
expand_arg(Arg, { Acc1, Acc2 }) ->
402402
{ EArg, EAcc } = expand(Arg, Acc1),

lib/elixir/test/elixir/kernel/expansion_test.exs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,10 @@ defmodule Kernel.ExpansionTest do
389389
assert_raise CompileError, %r"invalid quoted expression: {1, 2, 3}", fn ->
390390
expand(quote do: unquote({ 1, 2, 3 }))
391391
end
392+
393+
assert_raise CompileError, %r"invalid quoted expression: #Function<", fn ->
394+
expand(quote do: unquote({ :sample, fn -> end }))
395+
end
392396
end
393397

394398
## Helpers

0 commit comments

Comments
 (0)