scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

Scala 2.13.9 with -Wnonunit-statement and xml literals result in false positives #12658

Open SimY4 opened 2 years ago

SimY4 commented 2 years ago

Reproduction steps

Scala version: 2.13.9

class C {
  val xml = <xml><elem></elem></xml>

  def some = xml
}

Problem

Warning produced on line 2: unused value of type scala.xml.NodeBuffer (add: Unitto discard silently)

Expected: the code compiles without warning.

SethTisue commented 2 years ago

good catch, thanks! @som-snytt will likely want to take a look

som-snytt commented 2 years ago

Thanks, I'll take a look. My umbrella ticket is https://github.com/scala/bug/issues/12653, but I'll follow up here.

I would not have thought to check XML -- in case there is another ticket for "things we never compile when we compile the compiler."

SethTisue commented 1 year ago

@som-snytt I'm putting this on Backlog, but feel free to try to fix it for 2.13.11 anyway, if you're so inclined :-)