Skip to content

DOTR Crashes on @main #7529

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

Closed
abhsrivastava opened this issue Nov 9, 2019 · 4 comments · Fixed by #7530
Closed

DOTR Crashes on @main #7529

abhsrivastava opened this issue Nov 9, 2019 · 4 comments · Fixed by #7530

Comments

@abhsrivastava
Copy link

abhsrivastava commented Nov 9, 2019

I installed dotty on my MacBook Pro. Version 0.20.0-RC1

I wrote the code below in a file called "Hello.scala"

@main def foo(s: String) : Unit =
  println(s"Hello $s")
DOTR crashes on Load of file I am successfully able to compile this code using `dotc Hello.scala` and I can run this code using `dotr foo "Hello"` but when I try to load this file in the DOTR REPL by doing `:load Hello.scala`. The REPL throws a very nasty error and crashes.
Error

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)]),<init>),List()), Select(Select(
Ident(_root_),scala),Serializable)),ValDef(_,SingletonTypeTree(Ident(rs$line$1)),EmptyTree),List(Import(Ident(Console),
List(ImportSelector(Ident(_),EmptyTree,EmptyTree))),DefDef(foo,List(),List(List(ValDef(s,Ident(String),EmptyTree))),
Ident(Unit),Apply(Ident(println),List(Apply(Select(Apply(Select(Select(Select(Ident(_root_),scala),StringContext),apply),
List(Typed(SeqLiteral(List(Literal(Constant(hello )), Literal(Constant())),TypeTree[TypeRef(TermRef(
ThisType(TypeRef(NoPrefix,module class scala)),module Predef),type String)]),
TypeTree[AppliedType(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class <repeated>),
List(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class scala)),module Predef),type String)))]))),s),
List(Typed(SeqLiteral(List(Ident(s)),TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Any)]),
TypeTree[AppliedType(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class <repeated>),

List(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Any)))]))))))))), TypeDef(foo,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)]),<init>),List())),ValDef(_,EmptyTree,EmptyTree),List(DefDef(main,List(),List(List(ValDef(args,TypeTree[AppliedType(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Array),List(TypeRef(ThisType(TypeRef(NoPrefix,module class lang)),class String)))],EmptyTree))),TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Unit)],Try(Apply(Ident(foo),List(Apply(Apply(TypeApply(Ident(parseArgument),List(TypeTree[TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class scala)),module Predef),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)])),EmptyTree,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)
@bishabosha
Copy link
Member

Hi I believe the code snippet is missing a closing brace, thanks for updating the steps to reproduce

@abhsrivastava
Copy link
Author

closing brace? scala 3 just needs indentation right.

@bishabosha
Copy link
Member

Sorry, I mean parentheses to close println

@abhsrivastava
Copy link
Author

Oh that I was a typo here when reporting the issue. I fixed it but the DOTR still crashes.

bishabosha added a commit to bishabosha/dotty that referenced this issue Nov 10, 2019
odersky added a commit to dotty-staging/dotty that referenced this issue Nov 18, 2019
odersky added a commit to dotty-staging/dotty that referenced this issue Nov 18, 2019
bishabosha added a commit that referenced this issue Nov 19, 2019
Fix #7529: Don't drop modifiers when desugaring extension methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants