From a5775dbd45c89a70b6f896765fcb769bf7c9132c Mon Sep 17 00:00:00 2001 From: ASDAlexander77 Date: Fri, 27 Nov 2026 15:56:19 +0000 Subject: [PATCH] @owned: read under -mm=own as under -mm=rc (comments) The compiler now honours `@owned` under -mm=own too (TSLANG 215), except for a declaration that lends its result (`@lends`, or a result type `this`). Co-Authored-By: Claude Opus 5.5 --- src/core/core.os.d.ts | 2 +- src/lib.d.ts | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/core/core.os.d.ts b/src/core/core.os.d.ts index 355b598..a811516 100644 --- a/src/core/core.os.d.ts +++ b/src/core/core.os.d.ts @@ -3,7 +3,7 @@ // under -mm=own so is every Date method that calls one: a global Date lent to `d.getMonth()` was an // error. The scalar ones too: a scalar declaration is taken as no-drops only in a module no function // value can escape from, and the library, which declares non-scalar functions, is not one. -// @owned: these return a string their caller owns under -mm=rc - each body returns `s`, a view of +// @owned: these return a string their caller owns under -mm=rc and -mm=own - each body returns `s`, a view of // its local char[], and a view the function returns is copied there (#481), so the caller is given // a string of its own at +1. Unmarked, they were C functions to their callers: the result was // copied again and the function's own string never given back (`toFixed` leaked one per call). diff --git a/src/lib.d.ts b/src/lib.d.ts index d6866db..4ebc71d 100644 --- a/src/lib.d.ts +++ b/src/lib.d.ts @@ -4,11 +4,13 @@ /// // @owned: lib.ts defines what this file declares, compiled under the program's own memory model, so -// under -mm=rc each function here returns a reference its caller owns, as an imported function does. -// Without it the compiler can say nothing of these results: every call kept its +1 for good, and one -// declaration with a heap result was enough to stop any call through a function value from giving -// its result back. Never on a C function, nor on one that returns a pointer into a buffer -// (core/core.os.d.ts's convertNumber, timestamp_to_string, ...). +// under -mm=rc and -mm=own each function here returns a value its caller owns, as an imported function +// does - except where a declaration says it lends its result (`@lends`, or a result type `this`), +// which -mm=own goes by. Without it the compiler can say nothing of these results: under rc every call +// kept its +1 for good, and one declaration with a heap result was enough to stop any call through a +// function value from giving its result back; under own no result was ever given back. Never on a C +// function, nor on one that returns a pointer into a buffer (core/core.os.d.ts's convertNumber, +// timestamp_to_string, ...). A function lib.ts makes lend its result must say `@lends` here too. @owned declare function parseInt(val: string, radix?: int): int;