Home > Net >  Scala 3 IntelliJ error: ';' expected but ':' found
Scala 3 IntelliJ error: ';' expected but ':' found

Time:09-17

I have a scala worksheet with the following code:

case class Square(width: Double):
  val area = width * width

val window = Square(2)
window.area

I am trying to code in IntelliJ Idea, but I am getting the following error:

';' expected but ':' found. case class Square(width: Double):

The code is written in Scala 3, and the IntelliSense is set up correctly and reports no error, but I have a suspicion that the compiler is using some older version of the language. Is this a compiler setup issue and how do I fix it?

Edit: I am following a Scala learning course and downloading my project from there: https://www.coursera.org/learn/effective-scala/supplement/UShnH/scala-3-repl-and-worksheets

CodePudding user response:

The file was part of the project from the course I mentioned in the question. There was a file build.properties containing a single line:

sbt.version=1.5.3

After changing the version to

sbt.version=1.7.1

and relaunching Idea, the worksheet was evaluated correctly with no errors. The project was also set up to use version Java 18, which is used by sbt 1.7.1, but sbt 1.5.3 uses Java 11 instead, which might have been the issue.

CodePudding user response:

case class Square(width; Double);
  • Related