Skip to content

Fuel-based inlining does reached max-inlines limit earlier then expected #26887

Description

@WojciechMazur

Based on the OpenCB failure in armanbilge/gcp4s (using circe/circe codecs derivation)

On 3.9.rc under -Xmax-lines 64 the following example was able to go through 63 iterations - that's the expected behaviour. Now, with fuel-based approach it fails during 49 nested invocation. It suggest the current tracking of inlines might be flowed, resulting in pre-mature failure. It might affect all ecosystem, forcing raising the max-lines limits in multiple projects

Compiler version

Last good release: 3.10.0-RC1-bin-20260813-afdb1e2-NIGHTLY
First bad release: 3.10.0-RC1-bin-20260816-3adfcbd-NIGHTLY

Bisect points to a4e1b44 / #25937

Minimized code

//> using options -Xmax-inlines 64

import scala.compiletime.{constValue, erasedValue}

inline def summonLabels[T <: Tuple]: List[String] =
  inline erasedValue[T] match
    case _: EmptyTuple => Nil
    case _: (t *: ts) => constValue[t].asInstanceOf[String] :: summonLabels[ts]

// Minimal 3.10 failure: first size over the new inline recursion limit.
val xs49: List[String] = summonLabels[(
  "f00", "f01", "f02", "f03", "f04", "f05", "f06", "f07", "f08", "f09",
  "f10", "f11", "f12", "f13", "f14", "f15", "f16", "f17", "f18", "f19",
  "f20", "f21", "f22", "f23", "f24", "f25", "f26", "f27", "f28", "f29",
  "f30", "f31", "f32", "f33", "f34", "f35", "f36", "f37", "f38", "f39",
  "f40", "f41", "f42", "f43", "f44", "f45", "f46", "f47", "f48"
)]

// Expected: last size that compiled on 3.9.0-RC6 with -Xmax-inlines 64.
val xs63: List[String] = summonLabels[(
  "f00", "f01", "f02", "f03", "f04", "f05", "f06", "f07", "f08", "f09",
  "f10", "f11", "f12", "f13", "f14", "f15", "f16", "f17", "f18", "f19",
  "f20", "f21", "f22", "f23", "f24", "f25", "f26", "f27", "f28", "f29",
  "f30", "f31", "f32", "f33", "f34", "f35", "f36", "f37", "f38", "f39",
  "f40", "f41", "f42", "f43", "f44", "f45", "f46", "f47", "f48", "f49",
  "f50", "f51", "f52", "f53", "f54", "f55", "f56", "f57", "f58", "f59",
  "f60", "f61", "f62"
)]

Output

-- Error: /Users/wmazur/projects/scala/community-build3/repro/armanbilge/gcp4s/test.scala:24:35 
24 |val xs: List[String] = summonLabels[(
   |                       ^
   |Recursion limit exceeded.
   |Maybe there is an illegal cyclic reference?
   |If that's not the case, you could try to increase the fuel and stack size: https://docs.scala-lang.org/overviews/compiler-options/compiling-deeply-nested-code.html
   |For the unprocessed stack overflow trace, compile with -Xno-enrich-error-messages.
   |A recurring operation is (inner to outer):
   |
   |  typing summonLabels[EmptyTuple.type]
   |  typing summonLabels[EmptyTuple.type].::
   |  typing summonLabels[EmptyTuple.type].::[String]

Expectation

Activity

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

Metadata

Metadata

Assignees

Labels

area:inlineitype:bugregressionThis worked in a previous version but doesn't anymorestat:needs triageEvery issue needs to have an "area" and "itype" label

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions