Skip to content

Commit

Permalink
Fix import error (#763)
Browse files Browse the repository at this point in the history
* Fix import error

This fix the error occurs when running any import statement. E.g.

import scala.util.Properties

cmd0.sc:7: not found: value res0
  .declareVariable("res0", res0); Iterator() },
                           ^Compilation Failed

Compilation Failed

Co-authored-by: Alexandre Archambault <alexandre.archambault@gmail.com>
  • Loading branch information
kiendang and alexarchambault authored Mar 14, 2021
1 parent e8f2202 commit f2e7752
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ class AlmondPreprocessor(
Some(extraCode0)
} else
None
case(_, _, t: G#Import) => None
case (_, code, t) =>
val ident = code
val extraCode0 =
Expand All @@ -186,7 +187,7 @@ class AlmondPreprocessor(
(resOpt, extraOpt) match {
case (None, _) => None
case (Some(res), None) => Some(res)
case (Some(res), Some(extra)) => Some(res)
case (Some(res), Some(extra)) =>
Some(res.copy(printer = s"{ $extra; Iterator() }" +: res.printer))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,9 @@ object ScalaInterpreterTests extends TestSuite {
.assertSuccess()
val Seq(after2) = outputHandler.displayed()
assert(after2.text == """[{"varName":"n","varSize":"","varShape":"","varContent":"2","varType":"Int","isMatrix":false},{"varName":"m","varSize":"","varShape":"","varContent":"4","varType":"Int","isMatrix":false}]""")

interpreter.execute("import scala.collection.mutable")
.assertSuccess()
}
}

Expand Down

0 comments on commit f2e7752

Please sign in to comment.