Skip to content
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

IllegalArgumentException during compile #9679

Open
scabug opened this issue Mar 1, 2016 · 4 comments
Open

IllegalArgumentException during compile #9679

scabug opened this issue Mar 1, 2016 · 4 comments

Comments

@scabug
Copy link

scabug commented Mar 1, 2016

compiling the below code results in

Error:scalac: Error: org.jetbrains.jps.incremental.scala.remote.ServerException
java.lang.IllegalArgumentException
	at scala.tools.asm.ByteVector.putUTF8(ByteVector.java:213)
	at scala.tools.asm.ClassWriter.newUTF8(ClassWriter.java:1092)
	at scala.tools.asm.MethodWriter.getSize(MethodWriter.java:2098)
	at scala.tools.asm.ClassWriter.toByteArray(ClassWriter.java:827)
	at scala.tools.nsc.backend.jvm.GenASM$JBuilder.writeIfNotTooBig(GenASM.scala:526)
	at scala.tools.nsc.backend.jvm.GenASM$JPlainBuilder.genClass(GenASM.scala:1341)
	at scala.tools.nsc.backend.jvm.GenASM$AsmPhase.emitFor$1(GenASM.scala:198)
	at scala.tools.nsc.backend.jvm.GenASM$AsmPhase.run(GenASM.scala:204)
	at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1501)
	at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1486)
	at scala.tools.nsc.Global$Run.compileSources(Global.scala:1481)
	at scala.tools.nsc.Global$Run.compile(Global.scala:1582)
	at xsbt.CachedCompiler0.run(CompilerInterface.scala:115)
	at xsbt.CachedCompiler0.run(CompilerInterface.scala:94)
	at xsbt.CompilerInterface.run(CompilerInterface.scala:22)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:101)
	at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:47)
	at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:41)
	at org.jetbrains.jps.incremental.scala.local.IdeaIncrementalCompiler.compile(IdeaIncrementalCompiler.scala:29)
	at org.jetbrains.jps.incremental.scala.local.LocalServer.compile(LocalServer.scala:26)
	at org.jetbrains.jps.incremental.scala.remote.Main$.make(Main.scala:67)
	at org.jetbrains.jps.incremental.scala.remote.Main$.nailMain(Main.scala:24)
	at org.jetbrains.jps.incremental.scala.remote.Main.nailMain(Main.scala)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.martiansoftware.nailgun.NGSession.run(NGSession.java:319)
package org.uwes.bleeding

import scala.util.parsing.combinator.RegexParsers

trait CParser extends RegexParsers  {
  def number:Parser[Int] = "[0-9]+".r ^^ {_.toInt}

  def ident:Parser[String]   = """[a-z]+""".r       ^^ { _.toString }

  def sexpr = repsep(",",expr0)
  def hier_ = "."  ~atom
  def scope_ = "::"~atom
  def array_ =  "["~expr0~"]"

  def function_ = rep("(" ~ sexpr ~ ")")
  def atom = number | ident | "(" ~ expr0 ~ ")"
  def l15 = atom ~ rep(function_ | array_ | hier_ | scope_)
  def l14 = rep("+"|"-"|"!"|"~"|"&"|"~&"|"|"|"~|"|"^"|"~^"|"^~") ~ l15
  def l13 = l14 ~ rep("**" ~ l14)
  def l12 = l13 ~ rep(("*"|"/"|"%") ~ l13)
  def l11 = l12 ~ rep(("+"|"-") ~ l12)
  def l10 = l11 ~ rep(("<<"|">>"|"<<<"|">>>") ~ l11)
  def l9 = l10 ~ rep(("<"|"<="|">"|">="|"inside"|"dist") ~ l10)
  def l8 = l9 ~ rep(("=="|"!="|"==="|"!=="|"==?"|"!=?") ~ l9)
  def l7 = l8 ~ rep("&" ~ l8)
  def l6 = l7 ~ rep(("^"|"~^"|"^~") ~ l7)
  def l5 = l6 ~ rep("|" ~ l6)
  def l4 = l5 ~ rep("&&" ~ l5)
  def l3 = l4 ~ rep("||" ~ l4)
  def l2 = l3 ~ rep("?:" ~ l3)
  def l1 = l2 ~ rep(("->"|"<->") ~ l2)
  def l0 = l1 ~ opt((":="|":/") ~ l1)
  def expr0:Parser[Any] = l0 | "{" ~ sexpr ~ "}" | "{{" ~ sexpr ~ "}}"
}
@scabug
Copy link
Author

scabug commented Mar 1, 2016

Imported From: https://issues.scala-lang.org/browse/SI-9679?orig=1
Reporter: uwe simm (uwe_simm)
Affected Versions: 2.11.7

@scabug
Copy link
Author

scabug commented Mar 1, 2016

@gourlaysama said:
That's some very nice type inference blow up...
For example, def l10's inferred return type is roughly 8.6M characters long. That's a bit much.

You can avoid it by manually annotating the return of your methods (with Parser[Any] probably here). It's generally a good thing to do anyway.

It still happens with GenBCode, and the error message could be improved (if I could figure out where to test for this exactly).

@scabug
Copy link
Author

scabug commented Mar 2, 2016

uwe simm (uwe_simm) said:
adding the types removes the problem. would be good to get a better indication to avoid the underlying problem
/uwe

@xuwei-k
Copy link

xuwei-k commented Aug 13, 2018

the error message could be improved

scala/scala-asm@d2f33ce

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

3 participants