summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@plataformatec.com.br>2019-08-14 14:48:02 +0200
committerJosé Valim <jose.valim@plataformatec.com.br>2019-08-14 14:51:49 +0200
commit4477115675f52b9b4234f974765aaaeb7036bbed (patch)
treeb22742ca56e1038f5d93a9aca48b9a66cf7764da
parent029a30000af825a2249194b1d521359c0d08c563 (diff)
downloadelixir-4477115675f52b9b4234f974765aaaeb7036bbed.tar.gz
Use an empty keyword list instead of nil for empty definitions
-rw-r--r--lib/elixir/lib/kernel.ex10
-rw-r--r--lib/elixir/src/elixir_bootstrap.erl4
-rw-r--r--lib/elixir/src/elixir_def.erl2
-rw-r--r--lib/iex/test/iex/helpers_test.exs2
4 files changed, 9 insertions, 9 deletions
diff --git a/lib/elixir/lib/kernel.ex b/lib/elixir/lib/kernel.ex
index 90d45b037..5b13927d0 100644
--- a/lib/elixir/lib/kernel.ex
+++ b/lib/elixir/lib/kernel.ex
@@ -4065,7 +4065,7 @@ defmodule Kernel do
end
"""
- defmacro def(call, expr \\ nil) do
+ defmacro def(call, expr \\ []) do
define(:def, call, expr, __CALLER__)
end
@@ -4095,7 +4095,7 @@ defmodule Kernel do
#=> ** (UndefinedFunctionError) undefined function Foo.sum/2
"""
- defmacro defp(call, expr \\ nil) do
+ defmacro defp(call, expr \\ []) do
define(:defp, call, expr, __CALLER__)
end
@@ -4123,7 +4123,7 @@ defmodule Kernel do
end
"""
- defmacro defmacro(call, expr \\ nil) do
+ defmacro defmacro(call, expr \\ []) do
define(:defmacro, call, expr, __CALLER__)
end
@@ -4139,7 +4139,7 @@ defmodule Kernel do
naming and default arguments.
"""
- defmacro defmacrop(call, expr \\ nil) do
+ defmacro defmacrop(call, expr \\ []) do
define(:defmacrop, call, expr, __CALLER__)
end
@@ -4630,7 +4630,7 @@ defmodule Kernel do
macro_definition =
case impls do
[] ->
- define(kind, call, nil, env)
+ define(kind, call, [], env)
[guard] ->
quoted =
diff --git a/lib/elixir/src/elixir_bootstrap.erl b/lib/elixir/src/elixir_bootstrap.erl
index 11ca72024..0d2275196 100644
--- a/lib/elixir/src/elixir_bootstrap.erl
+++ b/lib/elixir/src/elixir_bootstrap.erl
@@ -10,11 +10,11 @@
'MACRO-@'(Caller, Tree) ->
unless_loaded('MACRO-@', [Caller, Tree], fun() -> nil end).
-'MACRO-def'(Caller, Call) -> 'MACRO-def'(Caller, Call, nil).
+'MACRO-def'(Caller, Call) -> 'MACRO-def'(Caller, Call, []).
'MACRO-def'(Caller, Call, Expr) -> define(Caller, def, Call, Expr).
'MACRO-defp'(Caller, Call, Expr) -> define(Caller, defp, Call, Expr).
-'MACRO-defmacro'(Caller, Call) -> 'MACRO-defmacro'(Caller, Call, nil).
+'MACRO-defmacro'(Caller, Call) -> 'MACRO-defmacro'(Caller, Call, []).
'MACRO-defmacro'(Caller, Call, Expr) -> define(Caller, defmacro, Call, Expr).
'MACRO-defmacrop'(Caller, Call, Expr) -> define(Caller, defmacrop, Call, Expr).
diff --git a/lib/elixir/src/elixir_def.erl b/lib/elixir/src/elixir_def.erl
index 81429f563..46324545f 100644
--- a/lib/elixir/src/elixir_def.erl
+++ b/lib/elixir/src/elixir_def.erl
@@ -212,7 +212,7 @@ run_with_location_change(File, #{file := File} = E, Callback) ->
run_with_location_change(File, E, Callback) ->
elixir_lexical:with_file(File, E, Callback).
-def_to_clauses(_Kind, Meta, Args, [], nil, E) ->
+def_to_clauses(_Kind, Meta, Args, [], [], E) ->
check_args_for_function_head(Meta, Args, E),
[];
def_to_clauses(_Kind, Meta, Args, Guards, [{do, Body}], _E) ->
diff --git a/lib/iex/test/iex/helpers_test.exs b/lib/iex/test/iex/helpers_test.exs
index 47ddf3329..dc9821a80 100644
--- a/lib/iex/test/iex/helpers_test.exs
+++ b/lib/iex/test/iex/helpers_test.exs
@@ -382,7 +382,7 @@ defmodule IEx.HelpersTest do
"* def left == right\n\n @spec term() == term() :: boolean()\n\nguard: true\n\nReturns `true` if the two terms are equal.\n\n"
def_h =
- "* defmacro def(call, expr \\\\ nil)\n\nDefines a function with the given name and body."
+ "* defmacro def(call, expr \\\\ [])\n\nDefines a function with the given name and body."
assert capture_io(fn -> h(IEx.Helpers.pwd() / 0) end) =~ pwd_h
assert capture_io(fn -> h(IEx.Helpers.c() / 2) end) =~ c_h