Skip to content

Can't load modules from modules #149

@lihaoyi

Description

@lihaoyi

This doesn't seem to behave correctly in the following case:

// LimitImports.scala
val res = 1
@
val asd = 1
// Foo.scala
import ammonite.ops._

load.module(wd/"LimitImports.scala")

@

println(res)
println(asd)
@ // Repl Session
@ import ammonite.ops._
@ load.module(wd/"Foo.scala")
ammonite.repl.CompilationError: Compilation Failed
Main.scala:174: not found: value res
println(res)
        ^
Main.scala:177: not found: value asd
println(asd)
        ^
    ammonite.repl.interp.Interpreter.loop$1(Interpreter.scala:97)
    ammonite.repl.interp.Interpreter.processScript(Interpreter.scala:86)
    ammonite.repl.interp.Interpreter.processModule(Interpreter.scala:67)
    ammonite.repl.interp.Interpreter$$anon$1$load$.module(Interpreter.scala:134)
    cmd4$$anonfun$1.apply$mcV$sp(Main.scala:110)
    cmd4$.<init>(Main.scala:111)
    cmd4$.<clinit>(Main.scala:-1)

This should work. Will take some refactoring to make load.module put the imports in the right place depending on whether it's being called in a module or directly from the REPL, but shouldn't be hard in principle

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions