Skip to content

Commit 4d3d61e

Browse files
author
José Valim
committed
Deprecate :local.(args) syntax
1 parent 2e66218 commit 4d3d61e

File tree

9 files changed

+20
-32
lines changed

9 files changed

+20
-32
lines changed

lib/eex/lib/eex.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ defmodule EEx do
191191
def function_from_quoted(module, kind, name, args, source, info) do
192192
args = Enum.map args, fn arg -> { arg, [], nil } end
193193
quote = quote do
194-
unquote(kind).(unquote(name).(unquote_splicing(args)), do: unquote(source))
194+
unquote(kind)(unquote(name)(unquote_splicing(args)), do: unquote(source))
195195
end
196196
Module.eval_quoted module, quote, [], info
197197
end

lib/elixir/lib/kernel.ex

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,7 @@ defmodule Kernel do
12601260
defmacro defkv(keywords) do
12611261
Enum.map keywords, fn {k,v} ->
12621262
quote do
1263-
def unquote(k).() do
1263+
def unquote(k)() do
12641264
unquote(v)
12651265
end
12661266
end
@@ -1271,9 +1271,6 @@ defmodule Kernel do
12711271
12721272
defkv one: 1, two: 2
12731273
1274-
Notice in the example above, we define the function as `def unquote(k).()`
1275-
because each entry `k` is a an atom and invoking `def unquote(k)()`
1276-
would be invalid Elixir syntax.
12771274
"""
12781275
defmacro def(name, do: contents)
12791276

@@ -3051,7 +3048,7 @@ defmodule Kernel do
30513048
fun = Keyword.get(opts, :as, name)
30523049

30533050
quote do
3054-
def unquote(name).(unquote_splicing(args)) do
3051+
def unquote(name)(unquote_splicing(args)) do
30553052
apply unquote(target), unquote(fun), [unquote_splicing(actual_args)]
30563053
end
30573054
end

lib/elixir/lib/protocol.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ defmodule Protocol do
287287
# Generate all others protocols.
288288
defp each_impl_for({ kind, fun, _ }, _, _) do
289289
quote do
290-
defp __raw_impl__(arg) when unquote(fun).(arg) do
290+
defp __raw_impl__(arg) when unquote(fun)(arg) do
291291
__MODULE__.unquote(kind)
292292
end
293293
end
@@ -404,7 +404,7 @@ defmodule Protocol.DSL do
404404

405405
# Generate a fake definition with the user
406406
# signature that will be used by docs
407-
Kernel.def unquote(name).(unquote_splicing(args))
407+
Kernel.def unquote(name)(unquote_splicing(args))
408408

409409
{ args, body } = Protocol.DSL.args_and_body(__MODULE__, name, arity)
410410
Kernel.def unquote(name), args, [], do: body

lib/elixir/lib/record.ex

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,23 +131,23 @@ defmodule Record do
131131
end
132132

133133
contents = quote do
134-
defmacrop unquote(name).() do
134+
defmacrop unquote(name)() do
135135
Record.access(__MODULE__, unquote(escaped), [], __CALLER__)
136136
end
137137

138-
defmacrop unquote(name).(record) when is_tuple(record) do
138+
defmacrop unquote(name)(record) when is_tuple(record) do
139139
Record.to_keywords(__MODULE__, unquote(escaped), record)
140140
end
141141

142-
defmacrop unquote(name).(args) do
142+
defmacrop unquote(name)(args) do
143143
Record.access(__MODULE__, unquote(escaped), args, __CALLER__)
144144
end
145145

146-
defmacrop unquote(name).(record, key) when is_atom(key) do
146+
defmacrop unquote(name)(record, key) when is_atom(key) do
147147
Record.get(__MODULE__, unquote(escaped), record, key)
148148
end
149149

150-
defmacrop unquote(name).(record, args) do
150+
defmacrop unquote(name)(record, args) do
151151
Record.dispatch(__MODULE__, unquote(escaped), record, args, __CALLER__)
152152
end
153153
end
@@ -465,17 +465,17 @@ defmodule Record do
465465

466466
contents = quote do
467467
@doc false
468-
def unquote(key).(record) do
468+
def unquote(key)(record) do
469469
:erlang.element(unquote(i + 1), record)
470470
end
471471

472472
@doc false
473-
def unquote(key).(value, record) do
473+
def unquote(key)(value, record) do
474474
:erlang.setelement(unquote(i + 1), record, value)
475475
end
476476

477477
@doc false
478-
def unquote(update).(function, record) do
478+
def unquote(update)(function, record) do
479479
:erlang.setelement(unquote(i + 1), record,
480480
function.(:erlang.element(unquote(i + 1), record)))
481481
end

lib/elixir/src/elixir_translator.erl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,10 +468,11 @@ translate_each({ { '.', _, [Left, Right] }, Meta, Args } = Original, S) when is_
468468

469469
%% Anonymous function calls
470470

471-
translate_each({ { '.', _, [Expr] }, Meta, Args } = Original, S) ->
471+
translate_each({ { '.', Line, [Expr] }, Meta, Args } = Original, S) ->
472472
{ TExpr, SE } = translate_each(Expr, S),
473473
case TExpr of
474474
{ atom, _, Atom } ->
475+
elixir_errors:deprecation(?line(Line), S#elixir_scope.file, "the :~s.() syntax is deprecated, please use ~s() instead", [Atom, Atom]),
475476
translate_each({ Atom, Meta, Args }, S);
476477
_ ->
477478
case elixir_partials:handle(Original, S) of

lib/elixir/test/elixir/kernel/partial_application_test.exs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ defmodule Kernel.PartialApplicationTest do
1515
assert fun.(13, 6) == 7
1616
end
1717

18-
test :partial_with_atom_call_and_one_item do
19-
fun = :minus.(10, &1)
20-
assert fun.(5) == 5
21-
assert fun.(3) == 7
22-
end
23-
2418
test :partial_with_funcall_and_one_item do
2519
fun = minus(&1, &2)
2620
fun = fun.(10, &1)

lib/elixir/test/elixir/list_test.exs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@ Code.require_file "../test_helper.exs", __FILE__
33
defmodule ListTest do
44
use ExUnit.Case, async: true
55

6-
test :brackets_function do
7-
assert :[].(1,2,3) == [1,2,3]
8-
end
9-
106
test :optional_comma do
11-
assert :[].(1,) == [ 1, ]
12-
assert :[].(1,2,3,) == [1,2,3,]
7+
assert [1] == [ 1, ]
8+
assert [1,2,3] == [1,2,3,]
139
end
1410

1511
test :partial_application do

lib/elixir/test/elixir/tuple_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ defmodule TupleTest do
1212
end
1313

1414
test :optional_comma do
15-
assert :{}.(1,) == { 1, }
16-
assert :{}.(1, 2, 3) == { 1, 2, 3, }
15+
assert { 1 } == { 1, }
16+
assert { 1, 2, 3 } == { 1, 2, 3, }
1717
end
1818

1919
test :partial_application do

lib/ex_unit/lib/ex_unit/assertions.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ defmodule ExUnit.Assertions do
164164
quote do
165165
left = unquote(expected)
166166
right = unquote(actual)
167-
assert unquote(operator).(left, right), left, right, reason: unquote(text)
167+
assert unquote(operator)(left, right), left, right, reason: unquote(text)
168168
end
169169
end
170170

0 commit comments

Comments
 (0)