Skip to content

-Wunused:all and named function arguments #16678

Closed
@amumurst

Description

@amumurst

I tried adding the new unused flag (from #16157) to my work codebase and was surprised that it warned when a named arguments function defined inline gives unused warnings. This is even if it uses underscore.

Compiler version

With nightly: 3.3.0-RC1-bin-20230112-be10bc6-NIGHTLY

Minimized code

//> using scala "3.3.0-RC1-bin-20230112-be10bc6-NIGHTLY"
//> using option "-Wunused:all"

def foo(func: Int => String, value: Int): String = func(value)

println(foo(number => number.toString, value = 5)) //No warn
println(foo(func = number => number.toString, value = 5)) ///Warns twice
println(foo(func = _.toString, value = 5)) //Warns once

Output

[warn] ./unused-function-param.sc:7:20: unused explicit parameter
[warn] println(foo(func = number => number.toString, value = 5)) //Warns twice
[warn]                    ^^^^^^
[warn] ./unused-function-param.sc:7:27: unused local definition
[warn] println(foo(func = number => number.toString, value = 5)) //Warns twice
[warn]                           ^
[warn] ./unused-function-param.sc:8:20: unused local definition
[warn] println(foo(func = _.toString, value = 5)) //Warns once
[warn]  

Expectation

There is nothing unused here as far as I can tell, so it should not give a warning.

Metadata

Metadata

Assignees

Labels

area:reportingError reporting including formatting, implicit suggestions, etcitype:bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions