You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The matchesName method in scala.tools.nsc.transform.Constructors.scala currently matches any parameter which starts with the param.name, followed by the join symbol ($). This has the possibility of wrongly matching a parameter during compilation which will silently compile without warnings and introduce problems in runtime.
A minimal reproducible is easy, and will create the same problem in all use-case versions of Scala:
scala> case class Invoice(`total tax`: Int, total: Int)
defined class Invoice
scala> Invoice(`total tax` = 20, total = 120)
res0: Invoice = Invoice(20,20)
scala> res0.total
res1: Int = 20
@melezov said:
Ah, seems I only searched for constructor issues, my bad.
Also, my analysis seems to be a bit off as I didn't account for digits following $, so I closed the PR.
The
matchesName
method inscala.tools.nsc.transform.Constructors.scala
currently matches any parameter which starts with the param.name, followed by the join symbol ($). This has the possibility of wrongly matching a parameter during compilation which will silently compile without warnings and introduce problems in runtime.A minimal reproducible is easy, and will create the same problem in all use-case versions of Scala:
A proposal would be to change the method from
to
I'll make a PR with the failing test, to discuss the potential solution.
The text was updated successfully, but these errors were encountered: