Skip to content

Commit f400ac9

Browse files
committed
Mention patterns are not allowed in function heads
Closes #14496.
1 parent ca069f7 commit f400ac9

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/elixir/src/elixir_def.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ format_error({invalid_def, Kind, NameAndArgs}) ->
506506
io_lib:format("invalid syntax in ~ts ~ts", [Kind, 'Elixir.Macro':to_string(NameAndArgs)]);
507507

508508
format_error(invalid_args_for_function_head) ->
509-
"only variables and \\\\ are allowed as arguments in function head.\n"
509+
"patterns are not allowed in function head, only variables and default arguments (using \\\\)\n"
510510
"\n"
511511
"If you did not intend to define a function head, make sure your function "
512512
"definition has the proper syntax by wrapping the arguments in parentheses "

lib/elixir/test/elixir/kernel/errors_test.exs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,10 @@ defmodule Kernel.ErrorsTest do
870870

871871
test "invalid args for function head" do
872872
assert_compile_error(
873-
["nofile:2:7: ", "only variables and \\\\ are allowed as arguments in function head."],
873+
[
874+
"nofile:2:7: ",
875+
"patterns are not allowed in function head, only variables and default arguments (using \\\\)"
876+
],
874877
~c"""
875878
defmodule Kernel.ErrorsTest.InvalidArgsForBodylessClause do
876879
def foo(nil)

0 commit comments

Comments
 (0)