Skip to content

No warning when tracking types that cannot be tracked #23371

Closed
@nrinaudo

Description

@nrinaudo

Compiler version

3.7.0

Minimized code

//> using scala 3.7.0
//> using option -language:experimental.captureChecking

@main def test =
  val i: Int^ = 1
  i

Output

This compiles

Expectation

It shouldn't compile, because i is escaping.

I understand that this behaviour is intended - there's no point tracking primitive types because they cannot capture anything. However, this can (and has!) caught developer unawares, and feels inconsistent with the following:

class A
@main def test =
  val a1: A = A()
  val a2: A^{a1} = A()

This fails to compile because you can't track a non-capturing variable. Why fail when trying to track a non-capturing variable, but not when tracking a variable that can never track anything?

Metadata

Metadata

Assignees

No one assigned

    Labels

    itype:bugstat:needs triageEvery issue needs to have an "area" and "itype" label

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions