Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different behavior with our without a starting 'println' line #194

Open
skyluc opened this issue Aug 25, 2014 · 0 comments
Open

Different behavior with our without a starting 'println' line #194

skyluc opened this issue Aug 25, 2014 · 0 comments

Comments

@skyluc
Copy link
Member

skyluc commented Aug 25, 2014

The following worksheet compiles and executes:

package t2237
object CodeInWorksheet {
  println("Something, anything")                  //> Something, anything

  case class A private[A] (i: Int)
  val a1 = A(1)                                   //> a1  : t2237.CodeInWorksheet.A = A(1)
}

While the following fails, with a blinking error:

package t2237
object CodeInWorksheet {
  case class A private[A] (i: Int)
  val a1 = A(1)   // blinking error here
}

It is the result of bug in Scala (SI-8821) and a strange behavior of the worksheet.

The worksheet wraps the code inside the execute method only from the first expression. If the first (and the last) elements of the worksheet are class/object/trait definition, they stay outside of the execute.

Everything should be inside the execute method, otherwise it could some inconsistency, like class and its companion object not in the same context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant