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
Interpreter / Compiler inconsistent #321
Comments
Imported From: https://issues.scala-lang.org/browse/SI-321?orig=1
|
David Hogarty (flyingsymbols) said: |
Ville Aine (heap) said: At least on 2.6.1-final, the initial error message is different: $$ scala
Welcome to Scala version 2.6.1-final.
Type in expressions to have them evaluated.
Type :help for more information.
scala> :l IntSet.scala
Loading IntSet.scala...
defined trait IntSet
<console>:8: error: not found: type NonEmptySet
new NonEmptySet(x, new EmptySet, new EmptySet)
^
defined class NonEmptySet
<console>:7: error: not found: type EmptySet
var x: IntSet = new EmptySet
^ If The reason for the first error is that that The second "not found" error follows from the first one: as the interpreter Now, the type mismatch errors are somewhat more involved. When the interpreter object line2$$object {
object $$iw{
object $$iw{
trait IntSet {
def incl(x: Int): IntSet
def contains(x: Int): Boolean
}
}
} And when a line references something that was defined in one of the previous object line3$$object {
object $$iw{
import line2$$object.$$iw.$$iw.IntSet;
object $$iw{
class EmptySet extends IntSet {
def contains(x: Int): Boolean = false
def incl(x: Int): IntSet =
new NonEmptySet(x, new EmptySet, new EmptySet)
}
}
}
;} When object line8$$object {
object $$iw{
import line4$$object.$$iw.$$iw.NonEmptySet;
import line7$$object.$$iw.$$iw.IntSet;
object $$iw{
class EmptySet extends IntSet {
[...] So, |
Geoffrey Alan Washburn (washburn) said: |
@odersky said: |
Edwin Fuquen (ed5) said: |
@retronym said (edited on May 27, 2012 7:59:33 PM UTC): |
When working through Scala By Example, I found an inconsistency in the interpreter vs. the compiler. If I have the following file ('IntSet.scala')
and run 'scala', then at the interpreter type ':load IntSet.scala' I get the following errors:
However, if I compile and then run with 'scalac IntSet.scala' and 'scala Exec', I get
As expected.
The two should have uniform semantics. An acceptably typed input to the compiler should be acceptably typed to the interpreter and REPL.
The text was updated successfully, but these errors were encountered: