Skip to content

Case class allows case-field named "productArity", which creates havoc with Product #14908

Open
@jraty

Description

@jraty

% scala -version
Scala code runner version 3.1.1 -- Copyright 2002-2022, LAMP/EPFL

Case class allows case-field with name productArity without any warning/error. This silently breaks functionality of Product.
It is not obvious that case class extends Product and field with productArity should not be used.
Suggestion: make productArity illegal as a case-field or at least warning.

Example:

object Bug {

  case class Problem(productArity : Int)

  def main(args : Array[String]) : Unit = {
    val cc = Problem(42)
    println("wtf?: "+cc.productArity) //42
  } 
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:desugarDesugaring happens after parsing but before typing, see desugar.scalaarea:reportingError reporting including formatting, implicit suggestions, etcitype:enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions