Scala compile fails because of whitespace on a negative literal assignment?

  Kiến thức lập trình

This code fails to compile with scala 2.13:

case class Foo(bar: String, baz: Int = -1)
val foo = Foo("foo", baz=-2)

Says Not found value baz. This looks weird, doesn’t it? Somehow, I have never encountered it before. Just wondering if someone knows of a reason why this should not be working? Or is it just a compiler bug, as basic as it looks?

Works fine if you add whitespace around (or even just after) the = … or if you use anything that’s not a negative literal constant instead of -2

LEAVE A COMMENT