Repository navigation
-mm=own: chains returning this, kept closures own captured parameters, local swapped with a field (TSLANG 39-42) - #801
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes TSLANG_ISSUES items 39-42, the
-mm=ownlimits found in the default library on 2026-11-09.39. A chain from a new value (
JsonValue.newObject().set(...).set(...)returned or kept). A methodwhose result type is
thisreturns the object it is called on:: thisimplies@lends("this"), andunder
-mm=owna body that returns another object of the type is an error. A method typed with itsclass that returns
thison every path gets the same fact from its body. When such a method is called on a temporary the caller ownsand uses no more, the temporary's release goes and the result is the caller's own (spec 78). The
-shareddeclaration printer writes: this. No decorator:: thisis 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
thisof 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
@keepsmay say so (spec 76). The error for a capturethat still cannot move names the variable.
42. A local exchanged with a place.
[data, this.data] = [this.data, data]is two counted reads, theplace refilled, then the local assigned, under every model; under own the refill hands the place's
value to the local (spec 77).
<T>xof a classT | undefinedis onets.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 errorexpectations updated (now naming the variable).
Pairs with ASDAlexander77/TypeScriptCompilerDefaultLib#87, making
JsonValue.set/pushreturnthis.🤖 Generated with Claude Code