Skip to content

Unused value warnings for XML literals starting with Scala 2.13.9 #650

Closed
@BennyMcBenBen

Description

@BennyMcBenBen

If I am using XML literals, then I am seeing compile warnings starting with Scala version 2.13.9. I am using the sbt-tpolecat plugin so these are actually compile errors for me.

Example:

import scala.xml.Elem

case class ToDoItem(name: String) {
  def toXml: Elem = {
    <to-do-item>
      <name>{name}</name>
    </to-do-item>
  }
}

Compile errors:

[error] ToDoItem.scala:5:5: unused value of type scala.xml.NodeBuffer (add `: Unit` to discard silently)
[error]     <to-do-item>
[error]     ^
[error] /ToDoItem.scala:6:7: unused value of type scala.xml.NodeBuffer (add `: Unit` to discard silently)
[error]       <name>{name}</name>

Is this a bug or are the new unused warnings incompatible with XML literals? What do you recommend? Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions