Skip to content

TypedPython: an ArrayParam function that calls user code compiles and diverges from CPython #203

Closed

Description

@b-re-w

Defect (identity). The ArrayParam contract (ir.py) says a function holding a list copy-in runs no user code, but neither the front end nor the verifier enforces it.

Reproduction on develop: def f(xs: list[float], cb: Callable[[], None]) -> float: cb(); return xs[0] compiles. With cb setting xs[0] = 100.0, compiled f returns 1.0 (it read its copy) while the interpreter returns 100.0. A store into the array followed by a callback is also overwritten by write-back.

Fix: the verifier rejects (the function stays interpreted with a reason) a function with an ArrayParam that is not closed. Not closed means it runs GetAttr, CallObject, Truth, CompareObj, ObjToFloat or OBJ BinOp, or calls a function that runs user code (the existing closedness fixpoint), or uses FieldGet/FieldSet/New, whose slow paths run user code after a class change.

Done when: the reproduction stays interpreted and equals CPython, there are IR-level verifier tests for each open node and for the transitive case, a mutation that drops the rule makes the end-to-end test fail, and the suite is green.

Activity

  1. added a commit that references this issue on Oct 17, 2026
  2. b-re-w commented on Oct 17, 2026

    @b-re-w
    MemberAuthor

    Landed in develop via #205.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions