Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/elixir/lib/module/types.ex
Original file line number Diff line number Diff line change
Expand Up @@ -464,14 +464,16 @@ defmodule Module.Types do
## Module errors

def format_error({:unused_args, {name, arity}}),
do: "default values for the optional arguments in #{name}/#{arity} are never used"
do:
"default values for the optional arguments in the private function #{name}/#{arity} are never used"

def format_error({:unused_args, {name, arity}, count}) when arity - count == 1,
do: "the default value for the last optional argument in #{name}/#{arity} is never used"
do:
"the default value for the last optional argument in the private function #{name}/#{arity} is never used"

def format_error({:unused_args, {name, arity}, count}),
do:
"the default values for the last #{arity - count} optional arguments in #{name}/#{arity} are never used"
"the default values for the last #{arity - count} optional arguments in the private function #{name}/#{arity} are never used"

def format_error({:unused_def, {name, arity}, :defp}),
do: "function #{name}/#{arity} is unused"
Expand Down
14 changes: 10 additions & 4 deletions lib/elixir/test/elixir/kernel/warning_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,10 @@ defmodule Kernel.WarningTest do

test "unused default args" do
assert_warn_eval(
["nofile:3:8: ", "default values for the optional arguments in b/3 are never used"],
[
"nofile:3:8: ",
"default values for the optional arguments in the private function b/3 are never used"
],
~S"""
defmodule Sample1 do
def a, do: b(1, 2, 3)
Expand All @@ -728,7 +731,7 @@ defmodule Kernel.WarningTest do
assert_warn_eval(
[
"nofile:3:8: ",
"the default value for the last optional argument in b/3 is never used"
"the default value for the last optional argument in the private function b/3 is never used"
],
~S"""
defmodule Sample2 do
Expand All @@ -741,7 +744,7 @@ defmodule Kernel.WarningTest do
assert_warn_eval(
[
"nofile:3:8: ",
"the default values for the last 2 optional arguments in b/4 are never used"
"the default values for the last 2 optional arguments in the private function b/4 are never used"
],
~S"""
defmodule Sample3 do
Expand All @@ -759,7 +762,10 @@ defmodule Kernel.WarningTest do
""") == ""

assert_warn_eval(
["nofile:3:8: ", "the default value for the last optional argument in b/3 is never used"],
[
"nofile:3:8: ",
"the default value for the last optional argument in the private function b/3 is never used"
],
~S"""
defmodule Sample5 do
def a, do: b(1, 2)
Expand Down
Loading