ponylang/ponyc

Non-sendable data seen as sendable

SeanTAllen opened this issue · 0 comments

In fixing a "more likely" error in recover code logic where non-sendable code was allowed to be used in a recover block (#4458), the straightforward fix introduced an issue where generic code that was previously correctly rejected for not being sendable is no longer rejected. Fortunately a later issue catches the code, but the error message is not at all helpful as it should have been caught at the sendability check.

We need to fix this case as well. @jasoncarr0 believes this will be a good amount of work, but more investigation is needed.

class A
class Bad[T]
  let _t: T! // We could also use T: Any #alias but that's more internal 
  new create(t: T!) =>
    this._t = t

  fun bad(): val->(T!) =>
    recover
      this._t    // has type this->(T!)
    end

actor Main
  new create(env: Env) =>
    let a: A ref = A
    let a_val: A val = Bad[A ref](a).bad()

Note the equivalent reified code is correctly marked as being a usage of non-sendable data

class A
class Bad
  let _t: A ref! // We could also use T: Any #alias but that's more internal
  new create(t: A ref!) =>
    this._t = t

  fun bad(): val->(A ref!) =>
    recover
      this._t    // has type this->(T!)
    end

actor Main
  new create(env: Env) =>
    let a: A ref = A
    let a_val: A val = Bad(a).bad()