Scalac hanging on phase typer of RegexParser

假如想象 提交于 2019-12-10 11:25:30

问题


I have a scala program which among other things has a parser-combinator. This is done by extending scala.util.parsing.combinator.RegexParsers. I had developed it using Scala 2.10 and all was working fine.

Yesterday I upgraded my system to Scala 2.11.4, together with IntelliJ 14.02 (not that it matters).

However, whenever I try to compile this program now, scalac hangs during this phase:

scalac: phase typer on MyParser.scala

I changed absolutely nothing to this code, I can't understand why it is hanging or from where I should start. IntelliJ had a warning about postfix operators for parser expressions like constants_def? or structure_def*, where the ? and * follow the token, and I added this line, because of the SIP: Language Modularization Features:

import scala.language.postfixOps

It didn't really have any effect and the problem is still the same.

How can I troubleshoot what is going on? I can't figure out from where to start understanding why the phase typer is just hanging indefinitely.


回答1:


It looks like a workaround is to add an explicit type:

def da_gd : Parser[Expression with TimedCondition] =
  pref_timed_gd | da_gd_conjunction |
  (empty_temporal: Parser[Expression with TimedCondition])

A stack dump shows that it's figuring out the type of the expr, and -Ytyper-debug shows the vicinity.

Since nothing good happens after midnight, I'll stop there.



来源:https://stackoverflow.com/questions/27583857/scalac-hanging-on-phase-typer-of-regexparser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!