Skip to content

Cannot recude inline match if pattern condition is private #22300

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

Closed
t9dupuy opened this issue Jan 2, 2025 · 0 comments · Fixed by #22305
Closed

Cannot recude inline match if pattern condition is private #22300

t9dupuy opened this issue Jan 2, 2025 · 0 comments · Fixed by #22305
Assignees
Milestone

Comments

@t9dupuy
Copy link

t9dupuy commented Jan 2, 2025

Compiler version

3.5.2

Minimized code

class Foo:

  inline def inlineMatch[T]: String =
    inline compiletime.erasedValue[T] match
      case _: EmptyTuple               => ""
      case _: (h *: _) if checkType[h] => ""

  private inline def checkType[T]: Boolean =
    inline compiletime.erasedValue[T] match
      case _: Int => true
      case _      => false

val foo = Foo()

foo.inlineMatch[(Int, Boolean)] // Error

Output

[error]    |cannot reduce inline match with
[error]    | scrutinee:  compiletime.package$package.erasedValue[(Int, Boolean)] : (Int, Boolean)
[error]    | patterns :  case _:EmptyTuple
[error]    |             case _:*:[h @ _, _ @  >: Nothing <: Any] if Foo_this.asInstanceOf[Foo].checkType[h]

Expectation

If this is indeed not supposed to work, I would expect a clearer error message.

@t9dupuy t9dupuy added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Jan 2, 2025
@jchyb jchyb self-assigned this Jan 3, 2025
@jchyb jchyb added area:inline and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Jan 3, 2025
@WojciechMazur WojciechMazur added this to the 3.6.4 milestone Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants