Skip to content

-mm=own: chains returning this, kept closures own captured parameters, local swapped with a field (TSLANG 39-42) - #801

Merged
ASDAlexander77 merged 5 commits into
mainfrom
own-issues-39-42
Nov 9, 2026
Merged

ASDAlexander77 merged 5 commits into
mainfrom
own-issues-39-42

Conversation

@ASDAlexander77

@ASDAlexander77 ASDAlexander77 commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Fixes TSLANG_ISSUES items 39-42, the -mm=own limits found in the default library on 2026-11-09.

39. A chain from a new value (JsonValue.newObject().set(...).set(...) returned or kept). A method
whose result type is this returns the object it is called on: : this implies @lends("this"), and
under -mm=own a body that returns another object of the type is an error. A method typed with its
class that returns this on every path gets the same fact from its body. When such a method is called on a temporary the caller owns
and uses no more, the temporary's release goes and the result is the caller's own (spec 78). The
-shared declaration printer writes : this. No decorator: : this is the one way to say it.

40. A back-reference from an arrow that captures. A closure body's box is its first argument, so the
member's this of an arrow is the parameter after it (spec 75).

41. A closure kept owns the parameters it captures. A closure stored into a field, a global or an
array, or given to a call that keeps it, owns what its box holds of the function's parameters (by copy
or in a cell), so the function keeps them and @keeps may say so (spec 76). The error for a capture
that still cannot move names the variable.

42. A local exchanged with a place. [data, this.data] = [this.data, data] is two counted reads, the
place refilled, then the local assigned, under every model; under own the refill hands the place's
value to the local (spec 77). <T>x of a class T | undefined is one ts.ValueOrDefault, a view.

Tests: own_chain_returns_this, own_closure_keeps_param, own_swap_local_field (own, rc, gc, none,
JIT and compiled), own_err_this_result_other, own_err_closure_kept_param_used; two error
expectations updated (now naming the variable).

Pairs with ASDAlexander77/TypeScriptCompilerDefaultLib#87, making JsonValue.set/push return this.

🤖 Generated with Claude Code

ASDAlexander77 and others added 5 commits November 9, 2026 19:25
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…anged with a field takes its value (items 40-42)

40: an arrow that captures something and stores a closure over its object
parameter into a field of that object is a back-reference, as one that
captures nothing is: the member's `this` of a closure body is the parameter
after its box (spec 75).

41: a closure that is kept (stored into a field, a global, an array, or
given to a call that keeps it) owns what its box holds of the function's
parameters, captured by copy or in a cell, so the function keeps them and
`@keeps` may say so (spec 76). The error for a capture that still cannot
move names it.

42: `[local, place] = [place, local]` reads and counts both values, then
refills the place and assigns the local; under -mm=own the refill's
release hands the place's value over to the local (spec 77). `<T>x` of a
class `T | undefined` is one select (ts.ValueOrDefault), a view of the
optional.

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ver back to the caller (item 39)

A method that returns `this` on every path has the fact __own_result_itself
beside its result borrow: the signature pass infers it from a body, and a
method whose result type is `this` says it (implying `@lends("this")`, which
a function only this module calls drops again). Under own a `: this` body
that returns another object is an error. The -shared declaration printer
writes `: this` for such a method.

After the facts settle, a call with the fact whose receiver is a temporary
the caller owns (fresh, or a call result that borrows nothing) and uses no
more but to release it loses those releases, and its result is fresh: a
chain from a new value can be returned or kept (spec 78).

Also specs 75-78 and the guide (closures kept, exchanging a local with a
place, methods returning `this`).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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