Skip to content

Commit a6cdc83

Browse files
author
José Valim
committed
No need to wrap quote do: nil in a block
1 parent 7b3bbe3 commit a6cdc83

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

lib/elixir/src/elixir_parser.yrl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,6 @@ build_tuple(Marker, Args) ->
506506

507507
%% Blocks
508508

509-
build_block([nil]) -> { '__block__', [], [nil] };
510509
build_block([{Op,_,[_]}]=Exprs) when ?rearrange_uop(Op) -> { '__block__', [], Exprs };
511510
build_block([{unquote_splicing,_,Args}]=Exprs) when
512511
length(Args) =< 2 -> { '__block__', [], Exprs };

lib/elixir/test/elixir/kernel/quote_test.exs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,23 +150,26 @@ defmodule Kernel.QuoteTest do
150150
assert { :->, _, [{[], _, 1}] } = (quote do: (-> 1))
151151
end
152152

153-
defmacrop dynamic_opts do
154-
[line: 3]
155-
end
156-
157-
test :quote_with_dynamic_opts do
158-
assert quote(dynamic_opts, do: bar(1, 2, 3)) == { :bar, [line: 3], [1, 2, 3] }
159-
end
160-
161153
test :bind_quoted do
162154
assert quote(bind_quoted: [foo: 1 + 2], do: foo) == { :__block__, [], [
163155
{ :=, [], [{ :foo, [], Kernel.QuoteTest }, 3] },
164156
{ :foo, [], Kernel.QuoteTest }
165157
] }
166158
end
167159

168-
test :quote_with_list_block do
160+
test :literals do
161+
assert (quote do: []) == []
162+
assert (quote do: nil) == nil
169163
assert (quote do [] end) == []
164+
assert (quote do nil end) == nil
165+
end
166+
167+
defmacrop dynamic_opts do
168+
[line: 3]
169+
end
170+
171+
test :with_dynamic_opts do
172+
assert quote(dynamic_opts, do: bar(1, 2, 3)) == { :bar, [line: 3], [1, 2, 3] }
170173
end
171174
end
172175

0 commit comments

Comments
 (0)