File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -732,6 +732,10 @@ defmodule ArgumentError do
732
732
) do
733
733
message =
734
734
cond do
735
+ not proper_list? ( args ) ->
736
+ "you attempted to apply a function named #{ inspect ( function ) } on module #{ inspect ( module ) } " <>
737
+ "with arguments #{ inspect ( args ) } . Arguments (the third argument of apply) must always be a proper list"
738
+
735
739
# Note that args may be an empty list even if they were supplied
736
740
not is_atom ( module ) and is_atom ( function ) and args == [ ] ->
737
741
"you attempted to apply a function named #{ inspect ( function ) } on #{ inspect ( module ) } . " <>
@@ -747,10 +751,6 @@ defmodule ArgumentError do
747
751
"you attempted to apply a function named #{ inspect ( function ) } on module #{ inspect ( module ) } . " <>
748
752
"However #{ inspect ( function ) } is not a valid function name. Function names (the second argument " <>
749
753
"of apply) must always be an atom"
750
-
751
- not is_list ( args ) ->
752
- "you attempted to apply a function named #{ inspect ( function ) } on module #{ inspect ( module ) } " <>
753
- "with arguments #{ inspect ( args ) } . Arguments (the third argument of apply) must always be a list"
754
754
end
755
755
756
756
{ % { exception | message: message } , stacktrace }
@@ -759,6 +759,9 @@ defmodule ArgumentError do
759
759
def blame ( exception , stacktrace ) do
760
760
{ exception , stacktrace }
761
761
end
762
+
763
+ defp proper_list? ( list ) when length ( list ) >= 0 , do: true
764
+ defp proper_list? ( _ ) , do: false
762
765
end
763
766
764
767
defmodule ArithmeticError do
Original file line number Diff line number Diff line change @@ -423,7 +423,11 @@ defmodule ExceptionTest do
423
423
424
424
assert blame_message ( 123 , & apply ( Kernel , :+ , & 1 ) ) ==
425
425
"you attempted to apply a function named :+ on module Kernel with arguments 123. " <>
426
- "Arguments (the third argument of apply) must always be a list"
426
+ "Arguments (the third argument of apply) must always be a proper list"
427
+
428
+ assert blame_message ( 123 , & apply ( Kernel , :+ , [ & 1 | 456 ] ) ) ==
429
+ "you attempted to apply a function named :+ on module Kernel with arguments [123 | 456]. " <>
430
+ "Arguments (the third argument of apply) must always be a proper list"
427
431
end
428
432
429
433
test "annotates function clause errors" do
You can’t perform that action at this time.
0 commit comments