File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -1046,7 +1046,7 @@ defmodule Kernel do
10461046
10471047 """
10481048 defmacro left + right do
1049- quote do: :erlang . + ( unquote ( left ) , unquote ( right ) )
1049+ quote do: __op__ ( :+ , unquote ( left ) , unquote ( right ) )
10501050 end
10511051
10521052 @ doc """
@@ -1059,7 +1059,7 @@ defmodule Kernel do
10591059
10601060 """
10611061 defmacro left - right do
1062- quote do: :erlang . - ( unquote ( left ) , unquote ( right ) )
1062+ quote do: __op__ ( :- , unquote ( left ) , unquote ( right ) )
10631063 end
10641064
10651065 @ doc """
@@ -1100,7 +1100,7 @@ defmodule Kernel do
11001100
11011101 """
11021102 defmacro left * right do
1103- quote do: :erlang . * ( unquote ( left ) , unquote ( right ) )
1103+ quote do: __op__ ( :* , unquote ( left ) , unquote ( right ) )
11041104 end
11051105
11061106 @ doc """
@@ -1117,7 +1117,7 @@ defmodule Kernel do
11171117
11181118 """
11191119 defmacro left / right do
1120- quote do: :erlang . / ( unquote ( left ) , unquote ( right ) )
1120+ quote do: __op__ ( :/ , unquote ( left ) , unquote ( right ) )
11211121 end
11221122
11231123 @ doc """
Original file line number Diff line number Diff line change @@ -4,6 +4,13 @@ defmodule Kernel.FnTest do
44 use ExUnit.Case , async: true
55 import CompileAssertion
66
7+ test "arithmetic constants on match" do
8+ assert ( fn 1 + 2 -> :ok end ) . ( 3 ) == :ok
9+ assert ( fn 1 - 2 -> :ok end ) . ( - 1 ) == :ok
10+ assert ( fn - 1 -> :ok end ) . ( - 1 ) == :ok
11+ assert ( fn + 1 -> :ok end ) . ( 1 ) == :ok
12+ end
13+
714 test "clause with ^" do
815 x = 1
916 assert ( fn ^ x -> :ok ; _ -> :error end ) . ( 1 ) == :ok
You can’t perform that action at this time.
0 commit comments