Classes in Worksheet in Scala-IDE cause error
Asked Answered
A

2

4

Just instantiating a class by typing the following into a Worksheet (note, Worksheet, created with File > New > Scala Worksheet, a .sc file, not a normal .scala file) and clicking Save causes a spurious error:

enter image description here

Mouseover:

enter image description here

"Multiple markers at this line - illegal start of simple expression - ';' expected but identifier found."

I doubt something as simple as this could have slipped through testing so maybe it's a configuration issue. I've tried it on 2 machines and get the same behaviour:

1) Windows 7 with Eclipse Helios

2) Windows XP with Eclipse Indigo - clean download from Typesafe website

Any ideas? Do other people get this on their setup?

Aurea answered 4/10, 2012 at 21:44 Comment(8)
@giladhoch thanks - what operating system are you using?Aurea
Works for me, too. I am using Win7 64Bit, JDK 1.6.0_31, Scala 2.9.3, Eclipse 3.7.2, Scala-IDE 2.1.0.nightly !Anastasio
@Peter that's odd then. The error only appears for me me when I click Save - did you save it and it displayed the result?Aurea
@LuigiPlinge Yes, I just created a new workspace with one scala project with only one file containing your object WorkSheet, saved, compiled and there is no error message.Anastasio
After hitting save, I get only the ';' expected error (Win7 64bit, Indigo, Scala 2.9.3)Knowle
@Keith actually, me too now. Still, good to know it's not just me.Aurea
Try to add a space between the class Foo line and the new Foo line.Knowledge
@Knowledge that does not help.Aurea
B
3

This bug was fixed in the Scala compiler, but the fix is not in the version shipped with the milestone release.

If you update to a nightly build of the Scala IDE, you should be able to use this code pattern.

Brashy answered 7/10, 2012 at 8:21 Comment(2)
Thanks, but I can't get the nightly build running. If I try to install it, I get a bunch of conflicting dependencies: pastebin.com/TL90ReEF. So I tried uninstalling the existing Scala IDE and now Eclipse won't boot at all (IllegalStateException).Aurea
It looks like a problem with the Typesafe IDE. We're looking into it.Brashy
M
4

During the Martin Odersky lectures on Coursera I noticed that he declares his classes outside the main object in his workbooks.

I hope this helps

object Worksheet {
  new Foo
}

class Foo
Macaw answered 5/10, 2012 at 15:8 Comment(1)
Yes, great course, just finished assignment 3... but an inner class is a 100% legitimate scala code, so I assume he is doing it for either scoping or to avoid the bug (p.s. I love the shaun the sheep / timmy time avatar)Dionysius
B
3

This bug was fixed in the Scala compiler, but the fix is not in the version shipped with the milestone release.

If you update to a nightly build of the Scala IDE, you should be able to use this code pattern.

Brashy answered 7/10, 2012 at 8:21 Comment(2)
Thanks, but I can't get the nightly build running. If I try to install it, I get a bunch of conflicting dependencies: pastebin.com/TL90ReEF. So I tried uninstalling the existing Scala IDE and now Eclipse won't boot at all (IllegalStateException).Aurea
It looks like a problem with the Typesafe IDE. We're looking into it.Brashy

© 2022 - 2024 — McMap. All rights reserved.