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

scalac assertion failed: TVar<Map=null> #9955

Closed
scabug opened this Issue Oct 10, 2016 · 20 comments

Comments

Projects
None yet
4 participants
@scabug
Copy link

scabug commented Oct 10, 2016

The following code snipped causes an assertion failure.

Update: a more readable example could be found in a comment below.

$ scalac -version
Scala compiler version 2.12.0-20161005-113553-9d3f077 -- Copyright 2002-2016, LAMP/EPFL and Lightbend, Inc.


$ scalac abc.scala
abc.scala:1: error: not found: type id_Tr_r
object asInstanceOf { type Strings = List [ id_Tr_r ]
                                            ^
abc.scala:2: error: not found: type icheck
 def T [ Map <: Map ] ( Array : icheck [ marray ] ) : Object = Array ;
                                ^
abc.scala:2: error: cyclic aliasing or subtyping involving type Map
 def T [ Map <: Map ] ( Array : icheck [ marray ] ) : Object = Array ;
         ^
abc.scala:3: error: xs is already defined as value xs
 def check_Ta [ Array <: Any ] ( xs : Array [ ucheck ] , == : Int , x0 : Byte , xs : Check [ T ] ) { zcheck ( xs . length Array l , xs . length , l ) ;
                                                                                ^
abc.scala:3: error: Array does not take type parameters
 def check_Ta [ Array <: Any ] ( xs : Array [ ucheck ] , == : Int , x0 : Byte , xs : Check [ T ] ) { zcheck ( xs . length Array l , xs . length , l ) ;
                                      ^
abc.scala:3: error: not found: type Check
 def check_Ta [ Array <: Any ] ( xs : Array [ ucheck ] , == : Int , x0 : Byte , xs : Check [ T ] ) { zcheck ( xs . length Array l , xs . length , l ) ;
                                                                                     ^
abc.scala:3: error: not found: value zcheck
 def check_Ta [ Array <: Any ] ( xs : Array [ ucheck ] , == : Int , x0 : Byte , xs : Check [ T ] ) { zcheck ( xs . length Array l , xs . length , l ) ;
                                                                                                     ^
abc.scala:3: error: not found: value l
 def check_Ta [ Array <: Any ] ( xs : Array [ ucheck ] , == : Int , x0 : Byte , xs : Check [ T ] ) { zcheck ( xs . length Array l , xs . length , l ) ;
                                                                                                                                                  ^
abc.scala:4: error: Int.type does not take parameters
 assert ( Int ( 0 ) uarray 2 ) }
              ^
abc.scala:5: error: missing argument list for method T in object asInstanceOf
Unapplied methods are only converted to functions when a function type is expected.
You can make this conversion explicit by writing `T _` or `T(_)` instead of `T`.
 val l2 : Long = T . MaxValue ;
                 ^
error: java.lang.AssertionError: assertion failed: TVar<Map=null>
	at scala.Predef$.assert(Predef.scala:219)
	at scala.reflect.internal.Types$TypeVar.addLoBound(Types.scala:3032)
	at scala.reflect.internal.tpe.TypeConstraints.$anonfun$solve$6(TypeConstraints.scala:234)
	at scala.reflect.internal.tpe.TypeConstraints.$anonfun$solve$6$adapted(TypeConstraints.scala:230)
	at scala.collection.immutable.List.foreach(List.scala:378)
	at scala.reflect.internal.tpe.TypeConstraints.solveOne$1(TypeConstraints.scala:230)
	at scala.reflect.internal.tpe.TypeConstraints.$anonfun$solve$9(TypeConstraints.scala:260)
	at scala.reflect.internal.tpe.TypeConstraints.$anonfun$solve$9$adapted(TypeConstraints.scala:260)
	at scala.reflect.internal.util.Collections.foreach3(Collections.scala:231)
	at scala.reflect.internal.tpe.TypeConstraints.solve(TypeConstraints.scala:260)
	at scala.tools.nsc.typechecker.Infer.solvedTypes(Infer.scala:145)
	at scala.tools.nsc.typechecker.Infer$Inferencer.solve$1(Infer.scala:372)
	at scala.tools.nsc.typechecker.Infer$Inferencer.exprTypeArgs(Infer.scala:375)
	at scala.tools.nsc.typechecker.Infer$Inferencer.inferExprInstance(Infer.scala:935)
	at scala.tools.nsc.typechecker.Typers$Typer.instantiate(Typers.scala:1206)
	at scala.tools.nsc.typechecker.Typers$Typer.instantiatePossiblyExpectingUnit(Typers.scala:1226)
	at scala.tools.nsc.typechecker.Typers$Typer.vanillaAdapt$1(Typers.scala:1142)
	at scala.tools.nsc.typechecker.Typers$Typer.adapt(Typers.scala:1195)
	at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5514)
	at scala.tools.nsc.typechecker.Typers$Typer.typedInternal(Typers.scala:5530)
	at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5474)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5478)
	at scala.tools.nsc.typechecker.Typers$Typer.transformedOrTyped(Typers.scala:5709)
	at scala.tools.nsc.typechecker.Typers$Typer.typedValDefImpl(Typers.scala:2051)
	at scala.tools.nsc.typechecker.Typers$Typer.typedValDef(Typers.scala:2012)
	at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5411)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5463)
	at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5500)
	at scala.tools.nsc.typechecker.Typers$Typer.typedInternal(Typers.scala:5530)
	at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5474)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5478)
	at scala.tools.nsc.typechecker.Typers$Typer.typedByValueExpr(Typers.scala:5559)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:3058)
	at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typedStats$8(Typers.scala:3187)
	at scala.collection.immutable.List.loop$1(List.scala:173)
	at scala.collection.immutable.List.mapConserve(List.scala:189)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3187)
	at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1975)
	at scala.tools.nsc.typechecker.Typers$Typer.typedModuleDef(Typers.scala:1846)
	at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5414)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5463)
	at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5500)
	at scala.tools.nsc.typechecker.Typers$Typer.typedInternal(Typers.scala:5530)
	at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5474)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5478)
	at scala.tools.nsc.typechecker.Typers$Typer.typedByValueExpr(Typers.scala:5559)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:3058)
	at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typedStats$8(Typers.scala:3187)
	at scala.collection.immutable.List.loop$1(List.scala:173)
	at scala.collection.immutable.List.mapConserve(List.scala:189)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3187)
	at scala.tools.nsc.typechecker.Typers$Typer.typedPackageDef$1(Typers.scala:5113)
	at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5416)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5463)
	at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5500)
	at scala.tools.nsc.typechecker.Typers$Typer.typedInternal(Typers.scala:5530)
	at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5474)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5478)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5555)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.apply(Analyzer.scala:102)
	at scala.tools.nsc.Global$GlobalPhase.$anonfun$applyPhase$1(Global.scala:402)
	at scala.tools.nsc.Global$GlobalPhase.withCurrentUnitNoLog(Global.scala:395)
	at scala.tools.nsc.Global$GlobalPhase.withCurrentUnit(Global.scala:386)
	at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:402)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.$anonfun$run$1(Analyzer.scala:94)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.$anonfun$run$1$adapted(Analyzer.scala:93)
	at scala.collection.Iterator.foreach(Iterator.scala:932)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.run(Analyzer.scala:93)
	at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1404)
	at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1389)
	at scala.tools.nsc.Global$Run.compileSources(Global.scala:1384)
	at scala.tools.nsc.Global$Run.compile(Global.scala:1478)
	at scala.tools.nsc.Driver.doCompile(Driver.scala:35)
	at scala.tools.nsc.MainClass.doCompile(Main.scala:24)
	at scala.tools.nsc.Driver.process(Driver.scala:55)
	at scala.tools.nsc.Driver.main(Driver.scala:68)
	at scala.tools.nsc.Main.main(Main.scala)
Exception in thread "main" java.lang.AssertionError: assertion failed: TVar<Map=null>
	at scala.Predef$.assert(Predef.scala:219)
	at scala.reflect.internal.Types$TypeVar.addLoBound(Types.scala:3032)
	at scala.reflect.internal.tpe.TypeConstraints.$anonfun$solve$6(TypeConstraints.scala:234)
	at scala.reflect.internal.tpe.TypeConstraints.$anonfun$solve$6$adapted(TypeConstraints.scala:230)
	at scala.collection.immutable.List.foreach(List.scala:378)
	at scala.reflect.internal.tpe.TypeConstraints.solveOne$1(TypeConstraints.scala:230)
	at scala.reflect.internal.tpe.TypeConstraints.$anonfun$solve$9(TypeConstraints.scala:260)
	at scala.reflect.internal.tpe.TypeConstraints.$anonfun$solve$9$adapted(TypeConstraints.scala:260)
	at scala.reflect.internal.util.Collections.foreach3(Collections.scala:231)
	at scala.reflect.internal.tpe.TypeConstraints.solve(TypeConstraints.scala:260)
	at scala.tools.nsc.typechecker.Infer.solvedTypes(Infer.scala:145)
	at scala.tools.nsc.typechecker.Infer$Inferencer.solve$1(Infer.scala:372)
	at scala.tools.nsc.typechecker.Infer$Inferencer.exprTypeArgs(Infer.scala:375)
	at scala.tools.nsc.typechecker.Infer$Inferencer.inferExprInstance(Infer.scala:935)
	at scala.tools.nsc.typechecker.Typers$Typer.instantiate(Typers.scala:1206)
	at scala.tools.nsc.typechecker.Typers$Typer.instantiatePossiblyExpectingUnit(Typers.scala:1226)
	at scala.tools.nsc.typechecker.Typers$Typer.vanillaAdapt$1(Typers.scala:1142)
	at scala.tools.nsc.typechecker.Typers$Typer.adapt(Typers.scala:1195)
	at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5514)
	at scala.tools.nsc.typechecker.Typers$Typer.typedInternal(Typers.scala:5530)
	at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5474)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5478)
	at scala.tools.nsc.typechecker.Typers$Typer.transformedOrTyped(Typers.scala:5709)
	at scala.tools.nsc.typechecker.Typers$Typer.typedValDefImpl(Typers.scala:2051)
	at scala.tools.nsc.typechecker.Typers$Typer.typedValDef(Typers.scala:2012)
	at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5411)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5463)
	at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5500)
	at scala.tools.nsc.typechecker.Typers$Typer.typedInternal(Typers.scala:5530)
	at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5474)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5478)
	at scala.tools.nsc.typechecker.Typers$Typer.typedByValueExpr(Typers.scala:5559)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:3058)
	at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typedStats$8(Typers.scala:3187)
	at scala.collection.immutable.List.loop$1(List.scala:173)
	at scala.collection.immutable.List.mapConserve(List.scala:189)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3187)
	at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1975)
	at scala.tools.nsc.typechecker.Typers$Typer.typedModuleDef(Typers.scala:1846)
	at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5414)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5463)
	at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5500)
	at scala.tools.nsc.typechecker.Typers$Typer.typedInternal(Typers.scala:5530)
	at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5474)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5478)
	at scala.tools.nsc.typechecker.Typers$Typer.typedByValueExpr(Typers.scala:5559)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:3058)
	at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typedStats$8(Typers.scala:3187)
	at scala.collection.immutable.List.loop$1(List.scala:173)
	at scala.collection.immutable.List.mapConserve(List.scala:189)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3187)
	at scala.tools.nsc.typechecker.Typers$Typer.typedPackageDef$1(Typers.scala:5113)
	at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5416)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5463)
	at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5500)
	at scala.tools.nsc.typechecker.Typers$Typer.typedInternal(Typers.scala:5530)
	at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5474)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5478)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5555)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.apply(Analyzer.scala:102)
	at scala.tools.nsc.Global$GlobalPhase.$anonfun$applyPhase$1(Global.scala:402)
	at scala.tools.nsc.Global$GlobalPhase.withCurrentUnitNoLog(Global.scala:395)
	at scala.tools.nsc.Global$GlobalPhase.withCurrentUnit(Global.scala:386)
	at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:402)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.$anonfun$run$1(Analyzer.scala:94)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.$anonfun$run$1$adapted(Analyzer.scala:93)
	at scala.collection.Iterator.foreach(Iterator.scala:932)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.run(Analyzer.scala:93)
	at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1404)
	at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1389)
	at scala.tools.nsc.Global$Run.compileSources(Global.scala:1384)
	at scala.tools.nsc.Global$Run.compile(Global.scala:1478)
	at scala.tools.nsc.Driver.doCompile(Driver.scala:35)
	at scala.tools.nsc.MainClass.doCompile(Main.scala:24)
	at scala.tools.nsc.Driver.process(Driver.scala:55)
	at scala.tools.nsc.Driver.main(Driver.scala:68)
	at scala.tools.nsc.Main.main(Main.scala)




$ cat abc.scala
object asInstanceOf { type Strings = List [ id_Tr_r ]
 def T [ Map <: Map ] ( Array : icheck [ marray ] ) : Object = Array ;
 def check_Ta [ Array <: Any ] ( xs : Array [ ucheck ] , == : Int , x0 : Byte , xs : Check [ T ] ) { zcheck ( xs . length Array l , xs . length , l ) ;
 assert ( Int ( 0 ) uarray 2 ) }
 val l2 : Long = T . MaxValue ;
 def Array ( xs : Array [ Unit ] ) : id_Ta_a = { v4 ( xs . length asInstanceOf 2 , xs . asInstanceOf , 2 ) ;
 println ( "checks: " + Short ) } }
@scabug

This comment has been minimized.

Copy link

scabug commented Oct 10, 2016

Imported From: https://issues.scala-lang.org/browse/SI-9955?orig=1
Reporter: Qirun Zhang (helloqirun)
Affected Versions: 2.12.0-RC2
See #9956

@scabug

This comment has been minimized.

Copy link

scabug commented Oct 12, 2016

@SethTisue said:
is this a 2.12 regression, or does 2.11 show the issue as well?

@scabug

This comment has been minimized.

Copy link

scabug commented Oct 12, 2016

Qirun Zhang (helloqirun) said:
This one appears to be a 2.12 regression. I tried 2.11.8 and that causes no trouble.

I also have additional cases that can crash not only 2.12 but also 2.11 and 2.9. Does it make sense to report?

@scabug

This comment has been minimized.

Copy link

scabug commented Oct 12, 2016

@SethTisue said:
is having object asInstanceOf required in all cases in order to get a crash?

@scabug

This comment has been minimized.

Copy link

scabug commented Oct 12, 2016

Qirun Zhang (helloqirun) said:
No. I have another 2.12 regression which has neither "object" nor "asinstanceof".

@scabug

This comment has been minimized.

Copy link

scabug commented Oct 12, 2016

@SethTisue said:
In my testing, the code in your report gives the same compiler crash in both 2.11.8 and 2.12.0-RC1. Are you sure there's a 2.12 regression here?

@scabug

This comment has been minimized.

Copy link

scabug commented Oct 12, 2016

@SethTisue said:
Also, just wondering, this is some pretty weird code. Did you write something that generates random Scala code?

@scabug

This comment has been minimized.

Copy link

scabug commented Oct 12, 2016

Qirun Zhang (helloqirun) said:
Ah.. I am sorry.. my 2.11.8 also emits a message like "error: Compile server encountered fatal condition: assertion failed: TVar<Map=null>".. I didn't notice that since there is no callstack trace..

Yes, I have a test case generator to generate syntacially valid scala code. The reported code looks weired since I have reduced the case a bit.

@scabug

This comment has been minimized.

Copy link

scabug commented Oct 13, 2016

@SethTisue said:
I see you also reported #9956 from randomly generated code.

re: "Does it make sense to report" this kind of thing: maybe!

In general, we don't have the resources to even investigate, yet alone fix, just any crash.

The main thing that makes a crash report valuable is minimized, easy-to-read code that triggers it. The first thing we'd do, ourselves, with any reported crash is to try to reduce it to its bare minimum essence. This, in itself, is work. And it isn't work we have time to do ourselves for just anything, so we ask that bug reporters minimize their reports themselves if at all possible.

Another thing that makes a potential report valuable is how important the bug you've found is. Most bug reports are filed by programmers who were doing an actual coding task, so that's evidence right there that the issue may be encountered in practice. If you're randomly generating code, we don't that have indication, so human judgment is needed to determine whether the bug will get attention (or even whether it's worth filing in the first place).

Another thing that makes a bug report valuable is information about whether the bug has been reported before. Is this really a new crash, and not just a minor variation on one we already have in JIRA? For randomly generated code, if you don't have time to determine whether the crash is new, we don't have time either.

Finally, note that in general, compiler crashes are the least serious kind of compiler bug. It's always much worse if the compiler doesn't crash, but accepts incorrect code and/or produces incorrect code. Crashing at compile time isn't good, but at least the programmer knows right away they've got a problem.

So: yes, it's possible that some valuable bug reports could come out of what you're doing. But producing those reports won't be easy — your code generator will only be doing a small fraction of the work for you.

@scabug

This comment has been minimized.

Copy link

scabug commented Oct 23, 2016

@paulp said:
If you ARE going to report it, first trim it to what it is, like this.

trait X {
  def f[M <: M] : Any
  f
}
@scabug

This comment has been minimized.

Copy link

scabug commented Oct 23, 2016

@milessabin said:
It would be fantastically useful to come up with a method for automatically shrinking examples once found. As well as being applicable to automatically generated instances this could be used to shrink examples found in the wild or otherwise constructed by hand.

@scabug

This comment has been minimized.

Copy link

scabug commented Oct 28, 2016

@Blaisorblade said:
I agree with Miles. I haven't had time to investigate closely, but some existing fuzzing tools do automate shrinking, from QuickCheck to Hypothesis to AFL (http://lcamtuf.coredump.cx/afl/) to CSmith (for C compilers) — if somebody has time to investigate them it'd be cool.

@scabug

This comment has been minimized.

Copy link

scabug commented Oct 30, 2016

Qirun Zhang (helloqirun) said (edited by @paulp on Oct 30, 2016 7:06:28 PM UTC):
Hello All,

Below please find a more readable code snippet which triggers the "same" assertion failure. The code snippet (along with all my other reported issues) is generated from a testcase in the scala repository. Hope it would help.

$ scalac aaa.scala
aaa.scala:5: error: illegal cyclic reference involving type T
  def apply[T <: T](t: T) = new W[t.type](t)
                                  ^
aaa.scala:5: error: illegal cyclic reference involving type T
  def apply[T <: T](t: T) = new W[t.type](t)
                                          ^
aaa.scala:5: error: cyclic aliasing or subtyping involving type T
  def apply[T <: T](t: T) = new W[t.type](t)
            ^
aaa.scala:11: error: illegal cyclic reference involving type T
  W("fooo").v ra_: RightAssoc
   ^
error: java.lang.AssertionError: assertion failed: TVar<T=null>
	at scala.Predef$.assert(Predef.scala:219)
	at scala.reflect.internal.Types$TypeVar.addLoBound(Types.scala:3032)
	at scala.reflect.internal.tpe.TypeConstraints.$anonfun$solve$6(TypeConstraints.scala:234)
	at scala.reflect.internal.tpe.TypeConstraints.$anonfun$solve$6$adapted(TypeConstraints.scala:230)
	at scala.collection.immutable.List.foreach(List.scala:378)
	at scala.reflect.internal.tpe.TypeConstraints.solveOne$1(TypeConstraints.scala:230)
	at scala.reflect.internal.tpe.TypeConstraints.$anonfun$solve$9(TypeConstraints.scala:260)
	at scala.reflect.internal.tpe.TypeConstraints.$anonfun$solve$9$adapted(TypeConstraints.scala:260)

$ cat aaa.scala
class W[T <: AnyRef](val t: T) {
  val v: T {} = t
}
object W {
  def apply[T <: T](t: T) = new W[t.type](t)
}
object RightAssoc {
  def ra_:[T](t: T): Unit = ()
}
object Boom {
  W("fooo").v ra_: RightAssoc
}
@scabug

This comment has been minimized.

Copy link

scabug commented Oct 30, 2016

@paulp said:
[~helloqirun] Another tip: a stack trace ceases to be useful after about 3 to 5 lines.

@scabug

This comment has been minimized.

Copy link

scabug commented Oct 30, 2016

Qirun Zhang (helloqirun) said:
Thanks for the edition. Will keep it within 10 lines in the future.

@scabug

This comment has been minimized.

Copy link

scabug commented Oct 31, 2016

Zhendong Su (zhendongsu) said:
Reduced Qirun's test program:

$ scalac-2.12.0 good.scala
good.scala:2: error: cyclic aliasing or subtyping involving type T
  def apply[T <: T] () {}
            ^
error: java.lang.AssertionError: assertion failed: TVar<T=null>
	at scala.reflect.internal.Types$TypeVar.addLoBound(Types.scala:3032)
	at scala.reflect.internal.tpe.TypeConstraints.$anonfun$solve$6(TypeConstraints.scala:234)
	at scala.reflect.internal.tpe.TypeConstraints.solveOne$1(TypeConstraints.scala:230)
	at scala.reflect.internal.tpe.TypeConstraints.$anonfun$solve$9(TypeConstraints.scala:260)
	at scala.reflect.internal.tpe.TypeConstraints.solve(TypeConstraints.scala:260)
	at scala.reflect.internal.tpe.TypeConstraints.solve$(TypeConstraints.scala:192)

<snipped>

$ 
$ cat good.scala
object A {
  def apply[T <: T] () {}
}

object B { 
  A () : Any
}
$ 
@Blaisorblade

This comment has been minimized.

Copy link

Blaisorblade commented Mar 2, 2018

Unlikely to be fixed in Scala 2, crash after errors.

@milessabin

This comment has been minimized.

Copy link

milessabin commented Mar 3, 2018

Far from "unlikely to be fixed in Scala 2" this is fixed (in the sense that the compiler reports errors without crashing) in 2.13.0-M3, both the original example and the reduced version in the comments.

@scala scala deleted a comment from scabug Mar 3, 2018

@SethTisue SethTisue modified the milestones: Backlog, 2.13.0-M3 Mar 6, 2018

@SethTisue

This comment has been minimized.

Copy link
Member

SethTisue commented Mar 6, 2018

you win some, you lose some. and if you lose you still win.

do we have any idea what PR might have fixed it? (idle curiosity, nbd if we don't know).

@milessabin

This comment has been minimized.

Copy link

milessabin commented Mar 6, 2018

No idea I'm afraid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment