bug icon indicating copy to clipboard operation
bug copied to clipboard

`mkAttributedQualifier(Unit, <none>)` assert failure

Open dijkstracula opened this issue 1 year ago • 0 comments

Reproduction steps

Scala version: 2.13.13

I'm filing this as distinct from https://github.com/scala/bug/issues/12965 and other similar issues as both the type in mkAttributedQualifier is distinct from tuple type parameters and also the stack trace I'm getting seems different (e.g. this is not during implicit resolution)

To reproduce this issue, kindly compile this project (on the nathan/nsc_crash branch):

➜  shapeless git:(nathan/nsc_crash) ✗ git log --oneline | head -n1
14446a1 repro test for scala compiler crash
➜  shapeless git:(nathan/nsc_crash) ✗ sbt compile
   [...]
[error] (Compile / compileIncremental) java.lang.AssertionError: assertion failed:
[error]   mkAttributedQualifier(Unit, <none>)
[error]      while compiling: /private/tmp/shapeless/src/main/scala/Ch4.scala
[error]         during phase: fields
[error]      library version: version 2.13.13
[error]     compiler version: version 2.13.13
[error]   reconstructed args: -bootclasspath /Users/ntaylor/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.13/scala-library-2.13.13.jar -classpath /private/tmp/shapeless/target/scala-2.13/classes:/Users/ntaylor/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/chuusai/shapeless_2.13/2.3.3/shapeless_2.13-2.3.3.jar
[error]
[error]   last tree to typer: Ident(x$1)
[error]        tree position: line 3 of /private/tmp/shapeless/src/main/scala/Ch4.scala
[error]             tree tpe: Int(42)
[error]               symbol: value x_=
[error]    symbol definition: x$1: Int(42) (a TermSymbol)
[error]       symbol package: <empty>
[error]        symbol owners: value x_= -> variable x -> object Ch5
[error]            call site: constructor Ch5 in object Ch5 in package <empty>
[error]
[error] == Source file context for tree position ==
[error]
[error]      1 import shapeless.syntax.singleton._
[error]      2 object Ch5 {
[error]      3   var x = 42.narrow
[error]      4 }
[error]      5
[error] Total time: 1 s, completed Apr 3, 2024, 11:36:10 AM

Top of the stack trace:

[error]         at scala.reflect.internal.SymbolTable.throwAssertionError(SymbolTable.scala:171)
[error]         at scala.reflect.internal.TreeGen.mkAttributedQualifier(TreeGen.scala:99)
[error]         at scala.reflect.internal.TreeGen.mkAttributedQualifier(TreeGen.scala:75)
[error]         at scala.tools.nsc.transform.Fields$FieldsTransformer.$anonfun$transform$1(Fields.scala:749)
[error]         at scala.reflect.internal.Trees.deriveDefDef(Trees.scala:2015)
[error]         at scala.reflect.internal.Trees.deriveDefDef$(Trees.scala:2013)
[error]         at scala.reflect.internal.SymbolTable.deriveDefDef(SymbolTable.scala:28)
[error]         at scala.tools.nsc.transform.Fields$FieldsTransformer.transform(Fields.scala:749)
  [...]

The good news is that while the project itself is a very small repro test, it depends on the shapeless library narrowing a value to its singleton/literal type - I have no intuition for what exactly is happening under the hood here as I am in the process of teaching myself a bit of typelevel programming using Shapeless.

Thanks! Nathan

dijkstracula avatar Apr 03 '24 16:04 dijkstracula