Skip to content

own: concatenations, constructor arguments and this-returning chains in global initializers (TSLANG 85) - #860

Merged
ASDAlexander77 merged 2 commits into
mainfrom
fix-own-item-85
Nov 15, 2026
Merged

ASDAlexander77 merged 2 commits into
mainfrom
fix-own-item-85

Conversation

@ASDAlexander77

@ASDAlexander77 ASDAlexander77 commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Fixes TSLANG_ISSUES 85, plus two related -mm=own gaps in a global's initializer found while fixing it.

1. Three or more joined strings (const EXPORTS = "Raygen,Miss," + "Hit," + "Group" in native_ts_graphics' sakura_forest_ser.ts) were refused, "takes a second reference". The inner sum is a temporary the initializer makes, reads and frees. moveIntoGlobals took its retain for one the global takes. A fresh string retained once and released once, read only by a concatenation, now loses the retain and keeps its release, as in a function body.

2. A joined string given to a call (const H = new Holder("x" + "y")) was refused the same way, even with two strings. Such an argument now passes that check. ownGlobalInitializerCalls, which runs after the facts, already moves it into a callee that keeps it, or keeps its release after a callee that only reads it.

3. A chain returning this on a new object (const B = new Bag().add("m").add("n" + "o"), with add(): this or an inferred return this) was refused as a borrow, even with a plain literal. Function bodies take the object over (spec 78), but only for calls in functions. The global step now does the same for a method call whose result is its own this, on an object the initializer made. That object becomes the global's own and its releases go.

Still refused: a chain on another global's object (const A = SHARED.add("q"), a second owner), a function returning its parameter (id(new V(1)), #638), and a call result that borrows a concatenated argument.

Tests:

  • tests/00tslang_issue_85.ts, every model, JIT and compiled.
  • own/own_err_global_concat_borrowed.ts and own/own_err_global_chain_other_global.ts.
  • Validation: ctest -R "own|tslang_issue|global|string|chain|json" passed 2710/2710. The new test also passes under own as an exe, optimized and with --di --opt_level=0.

🤖 Generated with Claude Code

ASDAlexander77 and others added 2 commits November 15, 2026 00:24
The inner sum of `"a" + "b" + "c"` in a global's initializer is a temporary the
initializer makes, reads and gives back itself. moveIntoGlobals took its retain for
a second reference the global takes. A fresh string retained once and released once,
read only by a concatenation, now keeps its release and loses the retain, as in a
function body.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…a global's initializer (TSLANG 85)

`const H = new Holder("x" + "y")` was refused ("takes a second reference"): the sum is
a call argument, which moveIntoGlobals did not accept. ownGlobalInitializerCalls,
after the facts, already moves it into a callee that keeps it, or leaves its release.

`const B = new Bag().add("m").add("n" + "o")`, with `add(): this`, was refused as a
borrow. A method call whose result is its own `this` (spec 78), on an object the
initializer made and gives to nothing after but its releases, now returns that object,
the global's own, as transferTemporaryReceivers does in function bodies. A chain on
another global's object, and a function returning its parameter (#638), stay errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77 ASDAlexander77 changed the title own: a global of three or more concatenated strings (TSLANG 85) own: concatenations, constructor arguments and this-returning chains in global initializers (TSLANG 85) Nov 15, 2026
@ASDAlexander77
ASDAlexander77 merged commit 9ba8364 into main Nov 15, 2026
8 checks passed
@ASDAlexander77
ASDAlexander77 deleted the fix-own-item-85 branch November 15, 2026 01:04
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