ReviewOS

home-lang/home

fix(types): isolate test ownership state and type string cloning

#830
Closed glennmichael123 opened this 8 days ago ·
8 days ago

Problem

The examples acceptance gate has two ownership-related failures:

  1. ItTestDecl bodies are checked in the preceding function's drop state. A string local named result is dropped at the end of one test; a later it(...) test reuses result for an integer, does not register a drop, and is falsely diagnosed as using the earlier dropped variable.
  2. ownership_test.home assigns one owned string directly to another binding and then uses both, even though Home's ownership tests define strings as move-only. The example comment claims both that strings move and that this use should work.

Scope

  • Add an ownership flow-state reset that preserves accumulated diagnostics and registered behavior.
  • Give function and it test bodies isolated ownership/drop/type environments and balanced scopes.
  • Recognize string.clone() / string.copy() as returning a string.
  • Update the ownership example to clone explicitly instead of weakening string move semantics.
  • Add focused checker regressions and re-run examples.

Acceptance criteria

  • Reusing a local name across adjacent test declarations cannot inherit dropped/moved state.
  • String clone/copy calls preserve their receiver for later use.
  • Direct string assignment remains a move.
  • ownership_test.home and strings.test.hm pass home check.

Part of #779 and #814.

8 days ago

Completed by a5faf23a2 on origin/main. Ownership facts now reset between callable/test bodies with balanced scopes, it declarations use isolated type/drop environments, and string clone/copy retain string result types. The ownership example now clones explicitly, preserving the established move-only string rule. Guarded verification: checker 74/74, no-JSC build 2,841 MB, examples 38 pass / 1 fail; both ownership_test.home and strings.test.hm now pass.

Sign in to comment on this issue.