diff --git a/ast/compile.go b/ast/compile.go index 1f99e096924..d3aa5d08b09 100644 --- a/ast/compile.go +++ b/ast/compile.go @@ -2236,7 +2236,11 @@ func (c *Compiler) rewriteLocalVars() { // Report an error for each unused function argument for arg := range unusedArgs { if !arg.IsWildcard() { - c.err(NewError(CompileErr, rule.Head.Location, "unused argument %v", arg)) + if rule.Default { + c.err(NewError(CompileErr, rule.Head.Location, "unused default function argument %v. (hint: use _ (wildcard variable) instead)", arg)) + } else { + c.err(NewError(CompileErr, rule.Head.Location, "unused argument %v", arg)) + } } } } diff --git a/ast/compile_test.go b/ast/compile_test.go index 8340a515b75..4494ab74693 100644 --- a/ast/compile_test.go +++ b/ast/compile_test.go @@ -5518,6 +5518,18 @@ func TestCheckUnusedFunctionArgVars(t *testing.T) { }, }, }, + { + note: "unused default function argvar", + module: `package test + default func(x) := 0`, + expectedErrors: Errors{ + &Error{ + Code: CompileErr, + Location: NewLocation([]byte("func(x) := 0"), "", 2, 12), + Message: "unused default function argument x. (hint: use _ (wildcard variable) instead)", + }, + }, + }, } t.Helper()