5

While playing around with regexps in Scala I wrote something like this:

scala> val y = "Foo"
y: java.lang.String = Foo

scala> y "Bar"

scala>

As you can see, the second statement is just silently accepted. Is this legal a legal statement, and if so, what does it do? Or is it a bug in the parser and there should be an error message?

0

1 Answer 1

5

This is indeed an error in the parser. It is fixed in scala 2.7.2 (which is RC6 at the moment)

$ ./scala
Welcome to Scala version 2.7.2.RC6 (Java HotSpot(TM) Client VM, Java 1.5.0_16).
Type in expressions to have them evaluated.
Type :help for more information.
scala> def y = "foo"
y: java.lang.String

scala> y "bar"
<console>:1: error: ';' expected but string literal found.
       y "bar"
         ^

scala> val x = "foo"
x: java.lang.String = foo

scala> x "foo"
<console>:1: error: ';' expected but string literal found.
       x "foo"
         ^

scala> "foo" "bar"
<console>:1: error: ';' expected but string literal found.
       "foo" "bar"
             ^
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.