Skip to content

JsonValue.set and push return this: chains from a new value under -mm=own - #87

Merged
ASDAlexander77 merged 2 commits into
mainfrom
own-chain-returns-this
Nov 9, 2026
Merged

ASDAlexander77 merged 2 commits into
mainfrom
own-chain-returns-this

Conversation

@ASDAlexander77

@ASDAlexander77 ASDAlexander77 commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

JsonValue.set and push return this (they already returned the object itself), so under -mm=own
a chain from a new value - JsonValue.newObject().set("a", ...).set("b", ...) - can be returned or
given to a parameter that keeps it, as under every other model. : this implies @lends("this"), so
the explicit @lends goes.

tests/json.ts drops its __MEMORY_MODEL__ != "own" branch: chained() runs under every model and
now also returns a chain (person()). The README's -mm=own note about chains goes.

Needs ASDAlexander77/TypeScriptCompiler#801 (TSLANG_ISSUES 39: a method whose result type is this gives a temporary
receiver back to its caller) and ASDAlexander77/TypeScriptCompiler#802 (an
indexer's set that returns a value; rebased onto #86, whose indexer writes go through set).

🤖 Generated with Claude Code

…=own

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts with #86 (JsonValue by key) in JsonValue's set() and push(), in
src/lib.ts and src/lib.d.ts: set() takes #86's `key: number | string` and
body, with this branch's `: this` result and no @Lends("this"); push()
returns `this` as here.

Tested with tslang built from TypeScriptCompiler main plus #800 and #801:
every test passes in release JIT under gc, rc, none and own (json.ts with
its chains, json_index.ts).

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