Skip to content

own: a value moved into a field, an array or a constructor, then used, is a borrow of it; warn on a missing --own-facts file (TSLANG 50-53) - #848

Merged
ASDAlexander77 merged 3 commits into
mainfrom
fix-own-items-50-51
Nov 14, 2026
Merged

ASDAlexander77 merged 3 commits into
mainfrom
fix-own-items-50-51

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

TSLANG_ISSUES 50-53, found by compiling every module of powder_sandbox's -mm=own build (native_ts_graphics fc6fe6c as its submodule) with the compiler from main. Write-ups are in TSLANG_ISSUES.md.

own: a value moved on, then used, is a borrow of where it went

Under -mm=own a value of the function's own that was moved somewhere and then used was refused, "used here after its value was moved". Each case now reads the value from its new place, read right after the move. That read is a borrow, which the existing checks follow through the calls in between with their facts. All three steps are in OwnershipSignatureFieldLocals.cpp, next to item 47's local-as-field reads.

  • 50, into a field: const layout = device.create(); this.layout = layout; if (!layout) ...; use(layout) (ntg core/nri_donut_blit.ts). This covers stores in nested regions, and an object stored into a T | null field, which is read back narrowed. Strings, which are copied, and Shared<T> handles, which are counted, are left as they were.
  • 52, pushed into a field array: this.textures.push(texture); this.views.push(texture.createView(...)) (ntg core/nri_donut_textures.ts). The value is read back as array[newLength - 1].
  • 53, kept by a constructor: const app = new App(sample); sample.use(), and this.frames.push(new Frame(viewSet)); viewSet.update(...). This applies only to a constructor in the module that stores the parameter as it is into a field nothing else in it writes, and where this doesn't escape. The read goes through the object's latest place, so through this.frames[last] when the object was pushed.

Anything that may release or overwrite the new place before the use is still refused, now as "borrows a field/an element but is used here after it may be released or overwritten". That covers an overwriting call, a pop, an element store, the array replaced, or the object given away or overwritten. This also closes a hole alpha127 had: a value moved into a field of a parameter, with the parameter then given away into a field that is cleared, was accepted, and the program printed 0 from freed memory.

51: a missing --own-facts file warns

A file named by --own-facts that doesn't exist was skipped without a word. Every call into that module was then taken to release anything, so the errors read as the program's own. powder_sandbox's build-own had only 27 of the 58 facts objects its compile lines name. A missing file still gives no facts, but tslang now prints warning: --own-facts: '<file>' does not exist; ....

Effect on powder_sandbox + native_ts_graphics under own (276 sources, every facts object built)

before 53 after 53
sources failing 149 143
"used here after its value was moved" 178 94
constructor-argument sites 93 11
push-then-use sites 72 13

powder_sandbox's own src/ compiles clean with each step. Six ntg examples compile now: bokeh, calibrated_timestamps, shader_debugprintf, simple_compute, simple_hdr, simple_pbr.

Also noted in TSLANG_ISSUES.md, for native_ts_graphics rather than the compiler: examples/dynamic_primitive_clipping.ts:223 passes an int to setDepthClip(enable: boolean), which #846 rejects under every model. The fix is clip != 0.

Tests

  • New tests: 00tslang_issue_50.ts, 00tslang_issue_52.ts and 00tslang_issue_53.ts, under every model, JIT and compiled.
  • New own error tests: own_err_moved_field_overwritten, own_err_moved_param_field_dropped, own_err_pushed_then_popped and own_err_kept_by_constructor_reset.
  • New ctest test-own-facts-missing-file.
  • own_err_read_after_move_global is still refused at all three of its sites, now with the borrow message.
  • ctest (Windows Release): 7202/7202.
  • DefaultLib main (3b49771) rebuilt with this compiler, release and debug, all four models. tests.ps1 for each model is running; results to follow in a comment.

🤖 Generated with Claude Code

ASDAlexander77 and others added 3 commits November 14, 2026 11:28
…ld; warn on a missing --own-facts file (TSLANG 50, 51)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…its last element (TSLANG 52)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…of that field (TSLANG 53)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77

Copy link
Copy Markdown
Owner Author

DefaultLib main (3b49771), built with this branch's compiler (release, and debug with TSLANG_DEBUG_CRT=/MT, as the release job does) in a clean clone: tests.ps1 passes for every model, release and debug, compiled and JIT, with no failures.

model each of release/debug x compile/jit
own 207/212 passed, 5 skipped
rc 208/212 passed, 4 skipped
gc 211/212 passed, 1 skipped
none 208/212 passed, 4 skipped

The skips are the tests that run under gc only (thread_gc_collect, weakmap_weakset, weakref_basic) plus the per-model skips tests.ps1 already makes. Windows only; no Linux/WSL run.

@ASDAlexander77
ASDAlexander77 merged commit ded33db into main Nov 14, 2026
8 checks passed
@ASDAlexander77
ASDAlexander77 deleted the fix-own-items-50-51 branch November 14, 2026 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant