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

duplicate keys in SWITCH #7290

Closed
scabug opened this issue Mar 22, 2013 · 6 comments
Closed

duplicate keys in SWITCH #7290

scabug opened this issue Mar 22, 2013 · 6 comments
Assignees
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Mar 22, 2013

scala: duplicate keys in SWITCH, can't pick arbitrarily one of them to evict, see #6011.
scala: uncaught exception during compilation: scala.reflect.internal.FatalError
scala: Error:
while compiling: M:\projects\weltkante\proto\lang\src\weltkante\scanner\Token.scala
during phase: jvm
library version: version 2.10.1
compiler version: version 2.10.1
reconstructed args: -classpath M:\projects\weltkante\proto\lang\out\production\lang -bootclasspath C:\dev\jdk6-32bit\jre\lib\resources.jar;C:\dev\jdk6-32bit\jre\lib\rt.jar;C:\dev\jdk6-32bit\jre\lib\sunrsasign.jar;C:\dev\jdk6-32bit\jre\lib\jsse.jar;C:\dev\jdk6-32bit\jre\lib\jce.jar;C:\dev\jdk6-32bit\jre\lib\charsets.jar;C:\dev\jdk6-32bit\jre\lib\modules\jdk.boot.jar;C:\dev\jdk6-32bit\jre\classes;C:\dev\scala\lib\scala-library.jar
last tree to typer: Literal(Constant(weltkante.scanner.TSymbol))
symbol: null
symbol definition: null
tpe: Class(classOf[weltkante.scanner.TSymbol])
symbol owners:
context owners: anonymous class anonfun$22 -> package scanner
== Enclosing template or block ==
Template( // val <local $anonfun>: , tree.tpe=weltkante.scanner.anonfun$22
"scala.runtime.AbstractFunction0", "scala.Serializable" // parents
ValDef(
private
"_"


)
// 3 statements
DefDef( // final def apply(): weltkante.scanner.TComment
final
"apply"
[]
List(Nil)
// tree.tpe=weltkante.scanner.TComment
Apply( // def (): weltkante.scanner.TComment in class TComment, tree.tpe=weltkante.scanner.TComment
new weltkante.scanner.TComment."" // def (): weltkante.scanner.TComment in class TComment, tree.tpe=()weltkante.scanner.TComment
Nil
)
)
DefDef( // final def apply(): Object
final
"apply"
[]
List(Nil)
// tree.tpe=Object
Apply( // final def apply(): weltkante.scanner.TComment, tree.tpe=weltkante.scanner.TComment
STokenFactories$$anonfun$22.this."apply" // final def apply(): weltkante.scanner.TComment, tree.tpe=()weltkante.scanner.TComment
Nil
)
)
DefDef( // def (): weltkante.scanner.anonfun$22

""
[]
List(Nil)
// tree.tpe=weltkante.scanner.anonfun$22
Block( // tree.tpe=Unit
Apply( // def (): scala.runtime.AbstractFunction0 in class AbstractFunction0, tree.tpe=scala.runtime.AbstractFunction0
STokenFactories$$anonfun$22.super."" // def (): scala.runtime.AbstractFunction0 in class AbstractFunction0, tree.tpe=()scala.runtime.AbstractFunction0
Nil
)
()
)
)
)
== Expanded type of tree ==
ConstantType(value = Constant(weltkante.scanner.TSymbol))
duplicate keys in SWITCH, can't pick arbitrarily one of them to evict, see #6011.
scala.reflect.internal.FatalError:
while compiling: M:\projects\weltkante\proto\lang\src\weltkante\scanner\Token.scala
during phase: jvm
library version: version 2.10.1
compiler version: version 2.10.1
reconstructed args: -classpath M:\projects\weltkante\proto\lang\out\production\lang -bootclasspath C:\dev\jdk6-32bit\jre\lib\resources.jar;C:\dev\jdk6-32bit\jre\lib\rt.jar;C:\dev\jdk6-32bit\jre\lib\sunrsasign.jar;C:\dev\jdk6-32bit\jre\lib\jsse.jar;C:\dev\jdk6-32bit\jre\lib\jce.jar;C:\dev\jdk6-32bit\jre\lib\charsets.jar;C:\dev\jdk6-32bit\jre\lib\modules\jdk.boot.jar;C:\dev\jdk6-32bit\jre\classes;C:\dev\scala\lib\scala-library.jar

last tree to typer: Literal(Constant(weltkante.scanner.TSymbol))
symbol: null
symbol definition: null
tpe: Class(classOf[weltkante.scanner.TSymbol])
symbol owners:
context owners: anonymous class anonfun$22 -> package scanner

== Enclosing template or block ==

Template( // val <local $anonfun>: , tree.tpe=weltkante.scanner.anonfun$22

"scala.runtime.AbstractFunction0", "scala.Serializable" // parents

ValDef(

private

"_"

<tpt>

<empty>

)

// 3 statements

DefDef( // final def apply(): weltkante.scanner.TComment

<method> final <triedcooking>

"apply"

[]

List(Nil)

<tpt> // tree.tpe=weltkante.scanner.TComment

Apply( // def <init>(): weltkante.scanner.TComment in class TComment, tree.tpe=weltkante.scanner.TComment

  new weltkante.scanner.TComment."<init>" // def <init>(): weltkante.scanner.TComment in class TComment, tree.tpe=()weltkante.scanner.TComment

  Nil

)

)

DefDef( // final def apply(): Object

<method> final <bridge>

"apply"

[]

List(Nil)

<tpt> // tree.tpe=Object

Apply( // final def apply(): weltkante.scanner.TComment, tree.tpe=weltkante.scanner.TComment

  STokenFactories$$anonfun$22.this."apply" // final def apply(): weltkante.scanner.TComment, tree.tpe=()weltkante.scanner.TComment

  Nil

)

)

DefDef( // def (): weltkante.scanner.anonfun$22

<method> <triedcooking>

"<init>"

[]

List(Nil)

<tpt> // tree.tpe=weltkante.scanner.anonfun$22

Block( // tree.tpe=Unit

  Apply( // def <init>(): scala.runtime.AbstractFunction0 in class AbstractFunction0, tree.tpe=scala.runtime.AbstractFunction0

    STokenFactories$$anonfun$22.super."<init>" // def <init>(): scala.runtime.AbstractFunction0 in class AbstractFunction0, tree.tpe=()scala.runtime.AbstractFunction0

    Nil

  )

  ()

)

)

)

== Expanded type of tree ==

ConstantType(value = Constant(weltkante.scanner.TSymbol))

duplicate keys in SWITCH, can't pick arbitrarily one of them to evict, see #6011.

at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:49)

at scala.tools.nsc.Global.abort(Global.scala:253)

at scala.tools.nsc.backend.jvm.GenASM$JPlainBuilder$jcode$.emitSWITCH(GenASM.scala:1849)

at scala.tools.nsc.backend.jvm.GenASM$JPlainBuilder.genJumpInstr$1(GenASM.scala:2515)

at scala.tools.nsc.backend.jvm.GenASM$JPlainBuilder.scala$tools$nsc$backend$jvm$GenASM$JPlainBuilder$$genInstr$1(GenASM.scala:2618)

at scala.tools.nsc.backend.jvm.GenASM$JPlainBuilder$$anonfun$genBlock$1$2.apply(GenASM.scala:2326)

at scala.tools.nsc.backend.jvm.GenASM$JPlainBuilder$$anonfun$genBlock$1$2.apply(GenASM.scala:2312)

at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)

at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:105)

at scala.tools.nsc.backend.icode.BasicBlocks$BasicBlock.foreach(BasicBlocks.scala:197)

at scala.tools.nsc.backend.jvm.GenASM$JPlainBuilder.genBlock$1(GenASM.scala:2312)

at scala.tools.nsc.backend.jvm.GenASM$JPlainBuilder.genBlocks$1(GenASM.scala:2244)

at scala.tools.nsc.backend.jvm.GenASM$JPlainBuilder.genCode(GenASM.scala:2856)

at scala.tools.nsc.backend.jvm.GenASM$JPlainBuilder.genMethod(GenASM.scala:1563)

at scala.tools.nsc.backend.jvm.GenASM$JPlainBuilder.genClass(GenASM.scala:1398)

at scala.tools.nsc.backend.jvm.GenASM$AsmPhase.run(GenASM.scala:119)

at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1582)

at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1556)

at scala.tools.nsc.Global$Run.compileSources(Global.scala:1552)

at scala.tools.nsc.Global$Run.compile(Global.scala:1661)

at xsbt.CachedCompiler0.run(CompilerInterface.scala:115)

at xsbt.CachedCompiler0.run(CompilerInterface.scala:89)

at xsbt.CompilerInterface.run(CompilerInterface.scala:27)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:74)

at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:36)

at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:30)

at sbt.compiler.AggressiveCompile$$anonfun$8$$anonfun$compileScala$1$1$$anonfun$apply$3$$anonfun$apply$1.apply$mcV$sp(AggressiveCompile.scala:77)

at sbt.compiler.AggressiveCompile$$anonfun$8$$anonfun$compileScala$1$1$$anonfun$apply$3$$anonfun$apply$1.apply(AggressiveCompile.scala:77)

at sbt.compiler.AggressiveCompile$$anonfun$8$$anonfun$compileScala$1$1$$anonfun$apply$3$$anonfun$apply$1.apply(AggressiveCompile.scala:77)

at sbt.compiler.AggressiveCompile.sbt$compiler$AggressiveCompile$$timed(AggressiveCompile.scala:135)

at sbt.compiler.AggressiveCompile$$anonfun$8$$anonfun$compileScala$1$1$$anonfun$apply$3.apply(AggressiveCompile.scala:76)

at sbt.compiler.AggressiveCompile$$anonfun$8$$anonfun$compileScala$1$1$$anonfun$apply$3.apply(AggressiveCompile.scala:73)

at scala.Option.foreach(Option.scala:236)

at sbt.compiler.AggressiveCompile$$anonfun$8$$anonfun$compileScala$1$1.apply(AggressiveCompile.scala:73)

at sbt.compiler.AggressiveCompile$$anonfun$8$$anonfun$compileScala$1$1.apply(AggressiveCompile.scala:73)

at scala.Option.foreach(Option.scala:236)

at sbt.compiler.AggressiveCompile$$anonfun$8.compileScala$1(AggressiveCompile.scala:73)

at sbt.compiler.AggressiveCompile$$anonfun$8.apply(AggressiveCompile.scala:118)

at sbt.compiler.AggressiveCompile$$anonfun$8.apply(AggressiveCompile.scala:61)

at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:24)

at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:22)

at sbt.inc.Incremental$.cycle(Incremental.scala:46)

at sbt.inc.Incremental$.compile(Incremental.scala:29)

at sbt.inc.IncrementalCompile$.apply(Compile.scala:20)

at sbt.compiler.AggressiveCompile.compile2(AggressiveCompile.scala:126)

at sbt.compiler.AggressiveCompile.compile1(AggressiveCompile.scala:44)

at org.jetbrains.jps.incremental.scala.local.CompilerImpl.compile(CompilerImpl.scala:66)

at org.jetbrains.jps.incremental.scala.local.LocalServer.compile(LocalServer.scala:23)

at org.jetbrains.jps.incremental.scala.remote.Main$.nailMain(Main.scala:31)

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:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at com.martiansoftware.nailgun.NGSession.run(Unknown Source)
@scabug
Copy link
Author

scabug commented Mar 22, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7290?orig=1
Reporter: Tobias (zarat)
Affected Versions: 2.10.0, 2.10.1
Attachments:

  • source.zip (created on Mar 23, 2013 6:27:10 AM UTC, 3918 bytes)

@scabug
Copy link
Author

scabug commented Mar 22, 2013

Tobias (zarat) said (edited on Mar 22, 2013 10:58:06 PM UTC):
The code in question compiled well in 2.9.1, after updating to 2.10.1 the compiler now fails with an uncaught exception.

Token.scala does not contain any switch, so no idea what it is complaining about.

The issue #6011 mentioned in the message claims that was something fixed in 2.10.0-M5 so I assume it appearing in 2.10.1 is something not covered by the fixed #6011

@scabug
Copy link
Author

scabug commented Mar 23, 2013

@magarciaEPFL said:
Please attach Token.scala to this ticket, or ideally a minimized version of it that still triggers the bug.

@scabug
Copy link
Author

scabug commented Mar 23, 2013

Tobias (zarat) said:
I've attached a subset of the source which still has the error. Even though the error message talks about Token.scala, if I just compile Token.scala without having Scanner.scala no error occurs (maybe dead code removal? or the error is really in Scanner.scala and the message is broken?)

@scabug
Copy link
Author

scabug commented Mar 23, 2013

@retronym said (edited on Mar 23, 2013 7:57:40 AM UTC):
Yes, the error reporting is pointing to the wrong file.

The line of code that triggers the problem:

case '!' | '%' | '&' | '\'' | '*' | '+' | ',' | '.' | '/' | '|' | ';' |
           '=' | '?' | '@' | '\\' | '^' | '`' | '|' | '~' | ':' => pushToken[TSymbol]

Note that '|' is duplicated.

Here's a minimal test case:

def foo(a: Char) = a match { case 'b' => 0 case 'a' | 'a' => 0 }
duplicate keys in SWITCH, can't pick arbitrarily one of them to evict, see SI-6011: 97, 97, 98
	at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:49)

By contrast, the redundant cases are collapsed here:

scala> def foo(a: Char) = a match { case 'b' => 0 case 'b' => 0 }
<console>:7: warning: unreachable code
       def foo(a: Char) = a match { case 'b' => 0 case 'b' => 0 }
                                                              ^

@scabug
Copy link
Author

scabug commented Mar 23, 2013

@retronym said:
scala/scala#2291

@scabug scabug closed this as completed Mar 28, 2013
@scabug scabug added the has PR label Apr 7, 2017
@scabug scabug added this to the 2.10.2-RC1 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants