scala / bug

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

1.->("Go to island.") and 1 -> "Go to island." are not equivalent #372

Closed scabug closed 13 years ago

scabug commented 16 years ago

Scala 2.6.1 final[[BR]] Hope this is the right place to fill a possible bug[[BR]]


scala> 1 -> "prr"
res93: (Int, java.lang.String) = (1,prr)

scala> 1.->("prr")
res92: (Double, java.lang.String) = (1.0,prr)

I'm just starting with scala, but my understanding is that a->b is compiled into a.->(b), so the two expressions would give the same result. But in my test results are different, probably because scala is considering the dot as decimal separator and not as operator.

Feature or bug?

scabug commented 16 years ago

Imported From: https://issues.scala-lang.org/browse/SI-372?orig=1 Reporter: prr

scabug commented 16 years ago

@dragos said: I'd say this has to do with the 'longest match' rule for the lexer, so I vote for a 'feature', but I find it a bit strange that the same doesn't happen for 'toString'.

scabug commented 16 years ago

Geoffrey Alan Washburn (washburn) said: Indeed

scala> 1.toString
res0: java.lang.String = 1

scala> (1.0).toString
res1: java.lang.String = 1.0

I am not sure why being followed by letters rather than symbols should affect how many glyphs are matched as part of the number.

scabug commented 16 years ago

@odersky said: There's a special rule in the Scanner to treat fractions. I have updated the spec to reflect this:

If a floating point literal in a program is followed by a token starting with a letter, there must be at least one intervening whitespace character between the two tokens.

scabug commented 15 years ago

@odersky said: Milestone 2.7.0 deleted