Skip to content

Top level tries kill repl #1367

Closed
Closed
@DarkDimius

Description

@DarkDimius

source: http://scalapuzzlers.com/#pzzlr-012

scala> var x = 0
x: Int = 0
scala> lazy val y = 1/x
java.lang.ArithmeticException: / by zero
    at .y(<console>:5)
    at RequestResult$.<init>(<console>:4)
    at RequestResult$.<clinit>(<console>)
    at RequestResult$result(<console>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMeth...
scala> try {
         println(y)
       } catch {
         case _ : Throwable =>
           x = 1
           println(y)
       }Exception in thread "main" scala.MatchError: ParsedTry(Block(List(),Apply(Ident(println),List(Ident(y)))),Match(EmptyTree,List(CaseDef(Typed(Ident(_),Ident(Throwable)),EmptyTree,Block(List(Assign(Ident(x),Literal(Constant(1)))),Apply(Ident(println),List(Ident(y))))))),EmptyTree) (of class dotty.tools.dotc.ast.untpd$ParsedTry)
    at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1225)
    at dotty.tools.dotc.ast.untpd$UntypedTreeAccumulator.foldOver(untpd.scala:446)
    at dotty.tools.dotc.repl.CompilingInterpreter$Request$StatementHandler$$anon$2.apply(CompilingInterpreter.scala:644)
    at dotty.tools.dotc.repl.CompilingInterpreter$Request$StatementHandler$$anon$2.apply(CompilingInterpreter.scala:640)
    at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1295)
    at dotty.tools.dotc.ast.untpd$UntypedTreeAccumulator.foldOver(untpd.scala:446)
    at dotty.tools.dotc.repl.CompilingInterpreter$Request$StatementHandler.<init>(CompilingInterpreter.scala:647)
    at dotty.tools.dotc.repl.CompilingInterpreter$Request$ValHandler.<init>(CompilingInterpreter.scala:665)
    at dotty.tools.dotc.repl.CompilingInterpreter$Request.dotty$tools$dotc$repl$CompilingInterpreter$Request$$chooseHandler(CompilingInterpreter.scala:330)
    at dotty.tools.dotc.repl.CompilingInterpreter$Request$$anonfun$4.apply(CompilingInterpreter.scala:340)
    at dotty.tools.dotc.repl.CompilingInterpreter$Request$$anonfun$4.apply(CompilingInterpreter.scala:340)
    at scala.collection.immutable.List.map(List.scala:273)
    at dotty.tools.dotc.repl.CompilingInterpreter$Request.<init>(CompilingInterpreter.scala:340)
    at dotty.tools.dotc.repl.CompilingInterpreter.interpret(CompilingInterpreter.scala:217)
    at dotty.tools.dotc.repl.CompilingInterpreter.interpret(CompilingInterpreter.scala:215)
    at dotty.tools.dotc.repl.AmmoniteReader$$anonfun$2.apply(AmmoniteReader.scala:19)
    at dotty.tools.dotc.repl.AmmoniteReader$$anonfun$2.apply(AmmoniteReader.scala:19)
    at dotty.tools.dotc.repl.CompilingInterpreter.delayOutputDuring(CompilingInterpreter.scala:103)
    at dotty.tools.dotc.repl.AmmoniteReader.incompleteInput(AmmoniteReader.scala:19)
    at dotty.tools.dotc.repl.AmmoniteReader$$anonfun$1.applyOrElse(AmmoniteReader.scala:31)
    at dotty.tools.dotc.repl.AmmoniteReader$$anonfun$1.applyOrElse(AmmoniteReader.scala:29)
    at scala.PartialFunction$Lifted.apply(PartialFunction.scala:223)
    at scala.PartialFunction$Lifted.apply(PartialFunction.scala:219)
    at dotty.tools.dotc.repl.ammonite.terminal.Filter$$anon$1$$anonfun$1$$anonfun$apply$1.apply(Filter.scala:21)
    at dotty.tools.dotc.repl.ammonite.terminal.Filter$$anon$1$$anonfun$1$$anonfun$apply$1.apply(Filter.scala:21)
    at scala.collection.Iterator$$anon$11.next(Iterator.scala:370)
    at scala.collection.Iterator$class.find(Iterator.scala:802)
    at scala.collection.AbstractIterator.find(Iterator.scala:1202)
    at dotty.tools.dotc.repl.ammonite.terminal.Filter$$anon$1$$anonfun$1.apply(Filter.scala:21)
    at dotty.tools.dotc.repl.ammonite.terminal.Filter$$anon$1$$anonfun$1.apply(Filter.scala:21)
    at dotty.tools.dotc.repl.ammonite.terminal.Terminal$.readChar$1(Terminal.scala:267)
    at dotty.tools.dotc.repl.ammonite.terminal.Terminal$.readLine(Terminal.scala:299)
    at dotty.tools.dotc.repl.AmmoniteReader.readLine(AmmoniteReader.scala:54)
    at dotty.tools.dotc.repl.InterpreterLoop.repl$default$1(InterpreterLoop.scala:74)
    at dotty.tools.dotc.repl.InterpreterLoop.repl(InterpreterLoop.scala:80)
    at dotty.tools.dotc.repl.InterpreterLoop.run(InterpreterLoop.scala:210)
    at dotty.tools.dotc.repl.REPL.doCompile(REPL.scala:43)
    at dotty.tools.dotc.Driver.process(Driver.scala:124)
    at dotty.tools.dotc.Driver.process(Driver.scala:93)
    at dotty.tools.dotc.Driver.process(Driver.scala:105)
    at dotty.tools.dotc.Driver.main(Driver.scala:132)
    at dotty.tools.dotc.repl.Main.main(Main.scala)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions