Skip to content

Capture leak by pattern matching on type parameter #23574

@noti0na1

Description

@noti0na1

Compiler version

3.7.3-RC1-bin-SNAPSHOT-nonbootstrapped-git-42fdd76

Minimized code

import language.experimental.captureChecking
import caps.*

trait IO

def assertIO[T](x: T): IO = x match
  case io: IO => io
  case _ => throw new Exception("Expected an IO instance")

def leakIO(x: IO^): IO = assertIO(x)

Output

Compile success

Expectation

Error at case io: IO => io, io should not be a pure IO.

Even with #23524, the bug still presents, because T is boxed, so the capture set of x is empty.

Since we don't have a way to represent the capture set boxed by a type parameter, the bug cannot be fixed easily.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions