Skip to content

inline boolean value is not simplified in some cases #24412

@eejbyfeldt

Description

@eejbyfeldt

Compiler version

3.7.4, 3.8.0-RC1-bin-20251113-8b5d445-NIGHTLY,

Minimized code

object test {
  import scala.compiletime.erasedValue

  inline def contains[T <: Tuple, E]: Boolean = inline erasedValue[T] match {
    case _: EmptyTuple => false
    case _: (_ *: tail) => contains[tail, E]
  }
  inline def check[T <: Tuple]: Unit = {
    inline if contains[T, Long] && false then ???
  }

  check[(String, Double)]
}

Output

[error] ./inline_and.scala:12:3
[error] Cannot reduce `inline if` because its condition is not a constant value: {
[error]   {
[error]     false:Boolean
[error]   }:Boolean
[error] }:Boolean && false
[error]   check[(String, Double)]
[error]   ^^^^^^^^^^^^^^^^^^^^^^^

Expectation

The code should compile.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions