Skip to content

Assertion failure in Parser#parArgumentExprs #2515

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
smarter opened this issue May 23, 2017 · 0 comments
Closed

Assertion failure in Parser#parArgumentExprs #2515

smarter opened this issue May 23, 2017 · 0 comments

Comments

@smarter
Copy link
Member

smarter commented May 23, 2017

Before #2432 this code was not parsed correctly but now it crashes in the parser:

class Foo @deprecated() (@deprecated() id: String)
        at scala.Predef$.assert(Predef.scala:156)
        at dotty.tools.dotc.parsing.Parsers$Parser.parArgumentExprs(Parsers.scala:1336)
        at dotty.tools.dotc.parsing.Parsers$Parser.parArgumentExprss(Parsers.scala:1411)
        at dotty.tools.dotc.parsing.Parsers$Parser.annot(Parsers.scala:1762)
        at dotty.tools.dotc.parsing.Parsers$Parser.annotations(Parsers.scala:1767)
        at dotty.tools.dotc.parsing.Parsers$Parser.annotations(Parsers.scala:1767)
        at dotty.tools.dotc.parsing.Parsers$Parser.annotsAsMods(Parsers.scala:1772)
        at dotty.tools.dotc.parsing.Parsers$Parser.constrModsOpt(Parsers.scala:2209)
        at dotty.tools.dotc.parsing.Parsers$Parser$$anonfun$23.apply(Parsers.scala:2201)
        at dotty.tools.dotc.parsing.Parsers$Parser$$anonfun$23.apply(Parsers.scala:2201)
        at dotty.tools.dotc.parsing.Parsers$Parser.fromWithinClassConstr(Parsers.scala:312)
        at dotty.tools.dotc.parsing.Parsers$Parser.classConstr(Parsers.scala:2201)
        at dotty.tools.dotc.parsing.Parsers$Parser.classDefRest(Parsers.scala:2192)
        at dotty.tools.dotc.parsing.Parsers$Parser.classDef(Parsers.scala:2188)
        at dotty.tools.dotc.parsing.Parsers$Parser.tmplDef(Parsers.scala:2168)
        at dotty.tools.dotc.parsing.Parsers$Parser.topStatSeq(Parsers.scala:2379)
        at dotty.tools.dotc.parsing.Parsers$Parser$$anonfun$compilationUnit$1.topstats$1(Parsers.scala:2533)
        at dotty.tools.dotc.parsing.Parsers$Parser$$anonfun$compilationUnit$1.apply(Parsers.scala:2538)
        at dotty.tools.dotc.parsing.Parsers$Parser$$anonfun$compilationUnit$1.apply(Parsers.scala:2503)
        at dotty.tools.dotc.parsing.Parsers$Parser.checkNoEscapingPlaceholders(Parsers.scala:386)
        at dotty.tools.dotc.parsing.Parsers$Parser.compilationUnit(Parsers.scala:2503)
        at dotty.tools.dotc.parsing.Parsers$Parser.parse(Parsers.scala:144)
        at dotty.tools.dotc.typer.FrontEnd$$anonfun$parse$1.apply$mcV$sp(FrontEnd.scala:43)
        at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:32)
        at dotty.tools.dotc.typer.FrontEnd.parse(FrontEnd.scala:39)
        at dotty.tools.dotc.typer.FrontEnd$$anonfun$runOn$1.apply(FrontEnd.scala:85)
        at dotty.tools.dotc.typer.FrontEnd$$anonfun$runOn$1.apply(FrontEnd.scala:85)
        at scala.collection.immutable.List.foreach(List.scala:392)
        at dotty.tools.dotc.typer.FrontEnd.runOn(FrontEnd.scala:85)
        at dotty.tools.dotc.Run$$anonfun$compileUnits$1$$anonfun$apply$mcV$sp$1.apply(Run.scala:82)
        at dotty.tools.dotc.Run$$anonfun$compileUnits$1$$anonfun$apply$mcV$sp$1.apply(Run.scala:79)
        at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
        at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:186)
        at dotty.tools.dotc.Run$$anonfun$compileUnits$1.apply$mcV$sp(Run.scala:79)
        at dotty.tools.dotc.Run$$anonfun$compileUnits$1.apply(Run.scala:67)
        at dotty.tools.dotc.Run$$anonfun$compileUnits$1.apply(Run.scala:67)
        at dotty.tools.dotc.util.Stats$.monitorHeartBeat(Stats.scala:76)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:67)
        at dotty.tools.dotc.Run.compileSources(Run.scala:64)
        at dotty.tools.dotc.Run.compile(Run.scala:48)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:26)
        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.Main.main(Main.scala)

/cc @odersky

odersky added a commit to dotty-staging/dotty that referenced this issue May 24, 2017
When doing the indentation-based syntax, I found a better hammer:
We can simply copy the Scanner at the current offset to create a
lookahead Scanner. With that, the logic for handling primary
constructor arguments could be greatly simplified. Most of
scala#2432 could be reverted.
@odersky odersky closed this as completed in eb1a686 Jan 7, 2018
odersky added a commit that referenced this issue Jan 7, 2018
Fix #2515: Fix handling constructor annotation arguments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant