新的dotty运行时完全死在我身上

星期六早上在这里。尝试学习新的Scala编译器dotty。

使用

安装在我的Mac上
brew install lampepfl/brew/dotty

安装成功。我有版本

dotr -version
Starting dotty REPL...
Dotty compiler version 0.20.0-RC1 -- Copyright 2002-2019,LAMP/EPFL

创建的目录

mkdir dotty

将此代码写在Hello.scala

import Console._
@main def foo(s: String) : Unit =
 println(s"Hello $s")

我能够编译它

dotc Hello.scala

有一大堆.class.tasty文件

接下来我做了

dotr
:load Hello.scala

现在,我得到了这样一个错误的巨大“爆炸”,而dotr运行时完全消失并退出了。

我做了什么导致爆炸?这不是友好的错误消息。

Exception in thread "main" scala.MatchError: PackageDef(Ident(<empty>),List(ValDef(rs$line$1,Ident(rs$line$1$),Apply(Select(New(Ident(rs$line$1$)),<init>),List())),TypeDef(rs$line$1$,Template(DefDef(<init>,List(),List(List()),TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Unit)],EmptyTree),List(Apply(Select(New(
TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,module class lang)),class Object)]),List()),Select(Select(
Ident(_root_),scala),Serializable)),ValDef(_,SingletonTypeTree(Ident(rs$line$1)),List(Import(Ident(Console),List(ImportSelector(Ident(_),EmptyTree,EmptyTree))),DefDef(foo,List(List(ValDef(s,Ident(String),Ident(Unit),Apply(Ident(println),List(Apply(Select(Apply(Select(Select(Select(Ident(_root_),StringContext),apply),List(Typed(SeqLiteral(List(Literal(Constant(hello )),Literal(Constant())),TypeTree[TypeRef(TermRef(
ThisType(TypeRef(NoPrefix,module Predef),type String)]),TypeTree[AppliedType(TypeRef(ThisType(TypeRef(NoPrefix,class <repeated>),List(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,type String)))]))),s),List(Typed(SeqLiteral(List(Ident(s)),class Any)]),List(TypeRef(ThisType(TypeRef(NoPrefix,class Any)))]))))))))),TypeDef(foo,List(Apply(Select(New(TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,List(DefDef(main,List(List(ValDef(args,class Array),class String)))],Try(Apply(Ident(foo),List(Apply(Apply(TypeApply(Ident(parseArgument),List(TypeTree[TypeRef(TermRef(ThisType(TypeRef(NoPrefix,type String)])),List(Ident(args),Literal(Constant(0)))),List(Ident(given_FromString_String))))),List(CaseDef(Bind(error,Typed(Ident(_),TypeTree[TypeRef(ThisType(TypeRef(ThisType(TypeRef(NoPrefix,module class util)),module class CommandLineParser$)),class ParseError)])),Apply(Ident(showError),List(Ident(error))))),EmptyTree))))))) (of class dotty.tools.dotc.ast.Trees$PackageDef)
    at dotty.tools.repl.CollectTopLevelImports.topLevelImports$1(CollectTopLevelImports.scala:23)
    at dotty.tools.repl.CollectTopLevelImports.run(CollectTopLevelImports.scala:28)
    at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:315)
    at scala.collection.immutable.List.map(List.scala:219)
    at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:316)
    at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:162)
    at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
    at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
    at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
    at dotty.tools.dotc.Run.runPhases$5(Run.scala:172)
    at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:180)
    at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
    at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:65)
    at dotty.tools.dotc.Run.compileUnits(Run.scala:187)
    at dotty.tools.dotc.Run.compileUnits(Run.scala:129)
    at dotty.tools.repl.ReplCompiler.runCompilationUnit(ReplCompiler.scala:156)
    at dotty.tools.repl.ReplCompiler.compile(ReplCompiler.scala:166)
    at dotty.tools.repl.ReplDriver.compile(ReplDriver.scala:227)
    at dotty.tools.repl.ReplDriver.interpret(ReplDriver.scala:193)
    at dotty.tools.repl.ReplDriver.run$$anonfun$1(ReplDriver.scala:136)
    at dotty.tools.repl.ReplDriver.withRedirectedOutput(ReplDriver.scala:148)
    at dotty.tools.repl.ReplDriver.run(ReplDriver.scala:137)
    at dotty.tools.repl.ReplDriver.interpretCommand(ReplDriver.scala:345)
    at dotty.tools.repl.ReplDriver.interpret(ReplDriver.scala:200)
    at dotty.tools.repl.ReplDriver.loop$1(ReplDriver.scala:127)
    at dotty.tools.repl.ReplDriver.runUntilQuit$$anonfun$1(ReplDriver.scala:130)
    at dotty.tools.repl.ReplDriver.withRedirectedOutput(ReplDriver.scala:148)
    at dotty.tools.repl.ReplDriver.runUntilQuit(ReplDriver.scala:130)
    at dotty.tools.repl.Main$.main(Main.scala:6)
    at dotty.tools.repl.Main.main(Main.scala)
hlw13781927235 回答:新的dotty运行时完全死在我身上

您未指定程序参数

PRIMARY KEY

ALTER TABLE运行REPL。在REPL中,$ dotr foo Illegal command line: more arguments expected $ dotr foo World Hello World 的意思是“解释文件中的行”。 dotr应该如何获取程序参数?

本文链接:https://www.f2er.com/3131673.html

大家都在问