Skip to content

[native/gba] E0425: a boxed closure cannot WRITE an outer module 'export let' — the cell is not captured for assignments #684

Description

@spacedevin

Summary

A boxed closure that WRITES a module-level export let fails to compile on the GBA target: the generated closure body emits *name.borrow_mut() = ... without the cell in scope → E0425.

error[E0425]: cannot find value `deadCol` in this scope
  --> src/main.rs:13691:437
   | ...  *deadCol.borrow_mut() = _v.clone(); _v };

Repro (minimal shape)

export let deadCol: i32 = -1

function makeCast() {
  function noteDeath(c: i32) { deadCol = c }   // write to outer exported let
  return { noteDeath: noteDeath }
}
let mk = [makeCast]
const M = mk[0]()
export function noteDeath(c: i32) { return M.noteDeath(c) }

Reads of the outer exported let capture fine; the WRITE path doesn't capture the VmRef cell into the closure. This blocks the factory-wrapping pattern that is currently the only game-side mitigation for the run()-frame stack ceiling (see the companion frame-size issue) on any module whose functions mutate their exported state — which is most of them.

Ask

Capture the module cell (<name>_cell) into boxed closures for assignments the same way reads are captured.

Activity

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