Skip to content

Context function parameter name leaks into scope #24375

@mbovel

Description

@mbovel

@Sporarum mentioned this in https://users.scala-lang.org/t/using-context-function-parameter-by-name-and-not-by-type/10658.

Compiler version

3.4..3.7.3

Minimized code

def foo(f: (x: Int) ?=> Int) = f(using 0)
@main def Main = println(foo(x))

Output

Compiles successfully, with x referring to the argument of the context function:

$ scala -S 3.4 ../test.scala
Compiling project (Scala 3.4.3, JVM (17))
Compiled project (Scala 3.4.3, JVM (17))
0

Expectation

x should be not found, as in < 3.4:

$ scala -S 3.3 ../test.scala
Compiling project (Scala 3.3.7, JVM (17))
[error] /localhome/bovel/test.scala:2:30
[error] Not found: x
[error] @main def Main = println(foo(x))
[error]                              ^
Error compiling project (Scala 3.3.7, JVM (17))
Compilation failed

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions