I just noticed that if you create a variable in the worksheet and then delete it, the interpreter will remember it will be the source of subtle bugs.
For example, create a function that accepts an implicit argument and declare an implicit value of the same type somewhere in the worksheet:
def sayHello(implicit name: String): String = s"Hello $name"
implicit val n = "Joe"
sayHello
It will work and produce "Hello Joe", which is correct. If we then remove the word implicit in front of n and rerun the worksheet, it will continue working because it remembers that n was declared as implicit and it's still in scope. This is obviously wrong.
I fixed it on my machine by sending :reset to the Scala interpreter before the worksheet is re-evaluated. I also added an additional check in the line formatter, which fixes the red exception that Atom sometimes throws when Scala encounters an error.
Please take a look at the pull request and tell me what you think :)
I just noticed that if you create a variable in the worksheet and then delete it, the interpreter will remember it will be the source of subtle bugs.
For example, create a function that accepts an implicit argument and declare an implicit value of the same type somewhere in the worksheet:
It will work and produce "Hello Joe", which is correct. If we then remove the word
implicitin front ofnand rerun the worksheet, it will continue working because it remembers thatnwas declared as implicit and it's still in scope. This is obviously wrong.I fixed it on my machine by sending
:resetto the Scala interpreter before the worksheet is re-evaluated. I also added an additional check in the line formatter, which fixes the red exception that Atom sometimes throws when Scala encounters an error.Please take a look at the pull request and tell me what you think :)