Repository navigation
own: lazily cached fields, @final methods (TSLANG 47, 48); escaping-capture use error; boolean assignment errors - #846
Merged
Conversation
…oolean assignment errors - -mm=own: an object a `const` names, captured by copy by a closure that escapes, is the closure's from the capture on; a later use is "captured by a closure that escapes, and is still used here". A closure stored once into a field of the object it captures is a back-reference and borrows it. - `(() => T) | null` fields and locals: the closure is the function value itself. - Assigning a boolean to a number or a string, or a number to a boolean, is an error, as in tsc. The CMake registrations and the shared ownership-facts helpers these use are in the next commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…TSLANG 47, 48)
TSLANG 47 (-mm=own): `let r = this.cached; if (!r) { r = new Q(); this.cached = r; } return r;`
- Before the facts, a read of a local where it provably holds what a field holds is read as the
field (OwnershipSignatureFieldLocals.cpp): a local declared from the field, or given a value just
moved into it. The local's first value, read by nothing then, is dropped.
- A store into a field tested empty on the way (`!f`, `f == null`, `f === undefined`, the else of
`if (f)`) frees nothing (fillsEmptyField). The signature pass decides each fill once, judging a
call in between by facts that count every fill as a drop, and pins it on the release.
- Diagnostics name a folded const under --di; "another variable" is gone.
TSLANG 48: a method can be @Final. It can't be overridden or be abstract, a call of it runs it
(directly, or through the vtable with the one callee known when imported), and the -shared
declaration printer writes it. Under own, a borrow ended by a call of an overridable method gets a
note naming the method and pointing at @Final.
Also: dropsInBody's `!releasesNothing(r) && a || b` counted a store into a number field as a drop.
Item 49 (three reduced own errors from powder_sandbox) is filed open in TSLANG_ISSUES.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… Release, off by default) 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.
TSLANG_ISSUES 47: a lazily cached field returned through a local (-mm=own)
let r = this.cached; if (!r) { r = new Q(); this.cached = r; } return r;now compiles and runs under own.OwnershipSignatureFieldLocals.cpp). Soreturn risreturn this.cached. Theconst-check form andr = nafterthis.cached = nwork the same way.!f,== null,=== undefined, else ofif (f)) frees nothing (fillsEmptyField). A getter that only fills drops nothing, so a second call no longer ends the first result's borrow.constis named under--di, and the'another variable'placeholder is gone.TSLANG_ISSUES 48:
@finalmethods@final. It can't be overridden or be abstract, and calls run that method: directly, or through the vtable with the one callee known when its class is imported.-shareddeclaration printer writes@final.@final.dropsInBodycounted a store into a number field as a drop.From the earlier session on this branch
(() => T) | nullfields and locals now work.TSLANG_ENABLE_LTCGCMake option for the compiler's own targets (MSVC Release, off by default).Still open
Item 49 is filed: three reduced own errors from powder_sandbox. A method that no module overrides is still taken as overridable when its class is exported.
@finalon accessors is accepted but does nothing yet.Tests
00tslang_issue_47.tsand00tslang_issue_48.ts, under every model.own_lazy_cache_*andown_final_method_*, under every model, JIT and compiled.own_err_*cases.final_method_*_error.ts.tests.ps1passes for own, rc, gc and none.🤖 Generated with Claude Code