Skip to content

Some -Wnonunit-statement can't be silenced with @annotation.nowarn #17741

Closed
@mrdziuban

Description

@mrdziuban

Compiler version

3.3.1-RC1

Minimized code

<foo>bar</foo>: @annotation.nowarn("msg=unused value")

Output

-- [E176] Potential Issue Error: test.scala:1:5 --------------
1 |  <foo>bar</foo>: @annotation.nowarn("msg=unused value")
  |       ^
  |       unused value of type xml.NodeBuffer

Expectation

The nowarn annotation should silence the warning. I've also tried using a -Wconf compiler option but still no luck.

I said "some" in the title because the issue doesn't happen for all non-Unit statements. I initially came across it with XML-literals in my code and found that it doesn't happen for other simple statements, e.g. this works properly

scala.util.Try(1): @annotation.nowarn("msg=unused value")

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions