Skip to content

Context function is eagerly applied inside a capture set #16944

Open
@reftrans

Description

@reftrans

Compiler version

Scala 3.2.2 and latest snapshot (250757732398b92cb6fc8f02e50526573f1ba2b9).

Minimized code

import language.experimental.captureChecking
def fn(ap: String ?=> Int)(using str: String): {ap} Int = ap(using str)

Output

Compile error:

4 |def fn(ap: String ?=> Int)(using str: String): {ap} Int = ap(using str)
  |                                                ^^
  |                                                ap.apply(str): Int is not a legal element of a capture set
1 error found

It compiles as expected if ap is a normal (non-context) function.

Expectation

Successful compilation, like with a normal function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions