Skip to content

An indexer's set: an imported class's gives up what it keeps, and the call has set's result (TSLANG 43) - #802

Merged
ASDAlexander77 merged 1 commit into
mainfrom
own-issue-43
Nov 9, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
own-issue-43

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Fixes TSLANG_ISSUES item 43 and two bugs found with it.

43. An imported class's indexer set that keeps its value (-mm=own). bag[key] = value on a class
imported from a library calls set through Cast(SearchForAddressOfSymbol("C.set")), which the
signature pass did not resolve, so the call had no facts and the caller freed what set kept: a
double free, and the program hung at exit. The callee now resolves to the function the module declares
by that name, so its @keeps/@lends apply as for bag.set(key, value) (spec 79).

An indexer set that returns a value, under every model. The call lowered for obj[key] = value
had no result even when set returns one (JsonValue.set(...): this), so it disagreed with the
function it calls and lowering to LLVM crashed tslang.exe now and then (about 1 run in 5 with the
default library's JsonValue indexer). The call now has the setter's results, unused.

@keeps with : this (-mm=own). A method returning this that declares @keeps, called only
in its module, was told to say @lends too; it keeps the @lends("this") its result type implies.

Tests: import_class_keeps_indexer.ts + export_class_keeps_indexer.ts (gc, rc, own; compiled and
JIT), 00class_indexer_set_result.ts. Full ctest locally 6913/6913; the default library with
TypeScriptCompilerDefaultLib#86 and #87 passes under own, rc, gc and none.

Needed by ASDAlexander77/TypeScriptCompilerDefaultLib#87 (with #801).

🤖 Generated with Claude Code

… call has set's result (TSLANG 43)

- -mm=own: `obj[key] = value` on a class imported from a library calls `set` through
  `Cast(SearchForAddressOfSymbol("C.set"))`; the signature pass now resolves that callee to the
  declared function, so its @keeps/@Lends apply and the caller no longer frees what `set` kept
  (double free, hang at exit).
- Every model: the call lowered for an indexer's `set` had no result even when `set` returns one
  (`JsonValue.set(...): this`), so it disagreed with its callee and LLVM lowering crashed now and
  then. It now has the setter's results, unused.
- -mm=own: a method returning `this` that declares `@keeps` keeps the `@lends("this")` its result
  type implies, instead of being told to say `@lends`.

Tests: import_class_keeps_indexer.ts/export_class_keeps_indexer.ts (gc, rc, own; compiled and JIT),
00class_indexer_set_result.ts. Spec 78 note, spec 79.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit 8cdff66 into main Nov 9, 2026
8 checks passed
@ASDAlexander77
ASDAlexander77 deleted the own-issue-43 branch November 9, 2026 21:08
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