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
732732 ) do
733733 message =
734734 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+
735739 # Note that args may be an empty list even if they were supplied
736740 not is_atom ( module ) and is_atom ( function ) and args == [ ] ->
737741 "you attempted to apply a function named #{ inspect ( function ) } on #{ inspect ( module ) } . " <>
@@ -747,10 +751,6 @@ defmodule ArgumentError do
747751 "you attempted to apply a function named #{ inspect ( function ) } on module #{ inspect ( module ) } . " <>
748752 "However #{ inspect ( function ) } is not a valid function name. Function names (the second argument " <>
749753 "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"
754754 end
755755
756756 { % { exception | message: message } , stacktrace }
@@ -759,6 +759,9 @@ defmodule ArgumentError do
759759 def blame ( exception , stacktrace ) do
760760 { exception , stacktrace }
761761 end
762+
763+ defp proper_list? ( list ) when length ( list ) >= 0 , do: true
764+ defp proper_list? ( _ ) , do: false
762765end
763766
764767defmodule ArithmeticError do
Original file line number Diff line number Diff line change @@ -423,7 +423,11 @@ defmodule ExceptionTest do
423423
424424 assert blame_message ( 123 , & apply ( Kernel , :+ , & 1 ) ) ==
425425 "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"
427431 end
428432
429433 test "annotates function clause errors" do
You can’t perform that action at this time.
0 commit comments