Skip to content

Unsoundness in CC with global objects and separate compilation #25758

@Linyxus

Description

@Linyxus

Compiler version

main

Minimized code

File 1:

import language.experimental.captureChecking
import caps.*
class IO extends SharedCapability:
  def println(msg: String): Unit = ()
val io: IO = new IO
def assertPure(op: () -> Unit): Unit = ()

File 2:

import language.experimental.captureChecking
import caps.*
def test1(): Unit =
  assertPure(() => io.println("hello"))  // error, as expected
def test2(): Unit =
  def test(): Unit = io.println("hello")
  assertPure: () =>  // should be error, but ok
    test()

Output

Only one error in test1.

Expectation

Both should be error.

Note that this is only triggered when the code is separate in two files. When test2 is in the same file with io, the error shows up as expected.

Metadata

Metadata

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions