scala> val I1: Int = 0 * * * 8 * 1 - 1 + 1 +
Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded
at scala.runtime.IntRef.create(IntRef.java:22)
at dotty.tools.dotc.ast.Trees$Tree.treeSize(Trees.scala:182)
at dotty.tools.dotc.ast.Trees$Tree.addSize$2(Trees.scala:184)
at dotty.tools.dotc.ast.Trees$Tree.treeSize$$anonfun$1(Trees.scala:188)
at dotty.tools.dotc.ast.Trees$Tree$$Lambda$786/1712635211.applyVoid(Unknown Source)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:563)
at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:561)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1279)
at dotty.tools.dotc.ast.Trees$Tree.treeSize(Trees.scala:188)
at dotty.tools.dotc.ast.Trees$Tree.addSize$2(Trees.scala:184)
at dotty.tools.dotc.ast.Trees$Tree.addSize$1$$anonfun$1(Trees.scala:185)
at dotty.tools.dotc.ast.Trees$Tree$$Lambda$853/2081703861.applyVoid(Unknown Source)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at scala.collection.immutable.List.foreach(List.scala:333)
at dotty.tools.dotc.ast.Trees$Tree.addSize$2(Trees.scala:185)
at dotty.tools.dotc.ast.Trees$Tree.treeSize$$anonfun$1(Trees.scala:188)
at dotty.tools.dotc.ast.Trees$Tree$$Lambda$786/1712635211.applyVoid(Unknown Source)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:563)
at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:561)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1279)
at dotty.tools.dotc.ast.Trees$Tree.treeSize(Trees.scala:188)
at dotty.tools.dotc.ast.Trees$Tree.addSize$2(Trees.scala:184)
at dotty.tools.dotc.ast.Trees$Tree.addSize$1$$anonfun$1(Trees.scala:185)
at dotty.tools.dotc.ast.Trees$Tree$$Lambda$853/2081703861.applyVoid(Unknown Source)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at scala.collection.immutable.List.foreach(List.scala:333)
REPL does not OOM.
For more information, see: https://github.com/lampepfl/dotty/issues/9344.
For context, this is a stock Dotty install, installed via brew on the following laptop:
Model Name: MacBook Pro
Model Identifier: MacBookPro14,3
Processor Name: Quad-Core Intel Core i7
Processor Speed: 3.1 GHz
Number of Processors: 1
Total Number of Cores: 4
L2 Cache (per Core): 256 KB
L3 Cache: 8 MB
Hyper-Threading Technology: Enabled
Memory: 16 GB
System Firmware Version: 429.60.3.0.0
@emilipy Some programs OOM. This one is particularly short. That has curiosity value, but is not by itself a bug. If you want to help, it would be good to try to get to the bottom why there is a OOM, and whether that's something that can be fixed.
@odersky Interesting take! Unfortunately, I am not the one to assign this to, as I have no free time to look at this within anything resembling a meaningful time frame. However, if you wanted, I'm sure @hrhino would love to attack this :)
@emilypi It's fine. I had another look. The root cause is that errors get propagated too far. They should truncate implicit searches but don't do it sufficiently well. The compiler is very lenient in that it does not report a type mismatch error if some participant is already erroneous. That's good to cut down on noise. But it also means that implicit searches can get out of hand, because too much is eligible.
Thanks for looking into that @odersky
Most helpful comment
@emilypi It's fine. I had another look. The root cause is that errors get propagated too far. They should truncate implicit searches but don't do it sufficiently well. The compiler is very lenient in that it does not report a type mismatch error if some participant is already erroneous. That's good to cut down on noise. But it also means that implicit searches can get out of hand, because too much is eligible.