Skip to content

own: a ?: of fresh values or null is the function's own; an array literal of fields, only read, borrows them (TSLANG 54, 55) - #849

Merged
ASDAlexander77 merged 2 commits into
mainfrom
fix-own-items-54
Nov 14, 2026
Merged

ASDAlexander77 merged 2 commits into
mainfrom
fix-own-items-54

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

TSLANG_ISSUES 54 and 55, found by compiling powder_sandbox's -mm=own build (native_ts_graphics as its submodule) with the compiler from main. Write-ups are in TSLANG_ISSUES.md. The rules for 55 are in section 80 of the own design spec.

54: a ?: of fresh values or null is the function's own

const pipeline = loaded ? device.createPipelineFromDesc(layout, desc) : null; ... this.blitPipelines.push(pipeline) (ntg core/nri_donut_textures.ts) was refused: "is merged from several branches; -mm=own cannot prove which one owns it yet".

  • isFresh now takes a merge block argument as fresh when every way in brings either a fresh value nothing else uses, or null or undefined (isFreshMerge, in OwnershipFacts.h). Nested ?: are followed. A loop header, where a predecessor the block dominates comes back to it, is not covered.
  • Items 50, 52 and 53 follow such a merge after it moves (ownValue).
  • Two checks took a block argument, which has no defining op, for a value made before a loop. checkReleasedOnce read the release at the end of one iteration as a second release of the next iteration's value. checkValueMoves read a move in the body as a move of a value made outside the loop. Both now take the argument as made where its block starts.
  • Still refused: c ? local : null with local used after, a merge moved twice, and a merge made before a loop and moved in it.

55: an array literal of fields, only read, borrows them

const directions = [this.dir, this.dir, this.right, ...] (ntg core/donut_first_person_camera.ts), const pipelines = [this.a, this.b, this.c], and for (const p of [this.a, this.b, extra]) were refused: "borrows a field and cannot be stored".

The new classifyLocalBorrowingArrays handles this case, next to spec 49's classifyArgumentArrays:

  • Which arrays qualify: a CreateArray held in a local or used as it is, read only through LengthOf and ElementRef → Load. Each of its block-holding elements must be a read out of a place or out of a parameter's slot, and nothing may keep it (walkRecord).
  • What changes for it: rc's element retains take nothing, and its Release and ReleaseSlot are marked shallow. ReleaseSlot lowering gained a branch for that (emitReleaseArrayShallow), so the same field twice is fine.
  • Bounds: every use of the array, and of what is read out of it, is a use of each element (arrayElementUses, read by walkBorrowed). A field written before such a use is still refused, as is a call that may write it. The array's own shallow release is not counted as a use.
  • Still refused: an array that is written, stored, returned, captured or passed to a call, a literal with a fresh element, and an element read out of the array and stored.

Effect on the sweep (276 sources, every facts object built)

  • Array literals of fields refused: 18 → 1. The one left, this.options = [...], stores the array, so the refusal is correct.
  • Merge errors left: 3.
  • nri_donut_textures.ts is down to one error, which is ntg's own: new MipBlit(texture, ...) keeps this.textures[t] a second time.
  • donut_first_person_camera.ts is down to two errors: a let that borrows a field and is then given a new array.
  • No file got worse, and powder_sandbox's own src/ compiles clean.

Tests

  • New tests: 00tslang_issue_54.ts and 00tslang_issue_55.ts, under every model, JIT and compiled. 55 was also run as an exe by hand.
  • New own error tests: own_err_merge_moved_twice and own_err_borrowing_array_field_reset.
  • ctest (Windows Release): 7220/7220.
  • DefaultLib main (0ec8870) builds with this compiler, release and debug, all four models.
  • tests.ps1 passes for every model, release and debug, compiled and JIT, with no failures. Windows only.
model each of release/debug × compile/jit
own 216/221 passed, 5 skipped
rc 217/221 passed, 4 skipped
gc 220/221 passed, 1 skipped
none 217/221 passed, 4 skipped

🤖 Generated with Claude Code

ASDAlexander77 and others added 2 commits November 14, 2026 12:56
…body too (TSLANG 54)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit a8db110 into main Nov 14, 2026
8 checks passed
@ASDAlexander77
ASDAlexander77 deleted the fix-own-items-54 branch November 14, 2026 14:05
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