Skip to content

[TS] Preserve evaluated constructor values in dynamic new expressions - #399

Merged
CaelmBleidd merged 3 commits into
neofrom
caelmbleidd/ts-398-dynamic-new-ir
Oct 3, 2026
Merged

CaelmBleidd merged 3 commits into
neofrom
caelmbleidd/ts-398-dynamic-new-ir

Conversation

@CaelmBleidd

@CaelmBleidd CaelmBleidd commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

Closes #398

Change

  • Add an optional evaluated constructor operand to NewExpr in the TS DTO, Kotlin DTO/model, JSON conversion, operand traversal, and validator. The existing static type remains a result type hint.
  • Lower dynamic new by evaluating and, when needed, snapshotting the constructor before arguments. Emit allocation after argument evaluation and preserve the selected value separately from a union result type.
  • Keep the standard-library Array allocation path specific to the actual standard-library identifier, so a dynamic constructor returning an array is retained as a dynamic NewExpr.
  • Mark computed access anywhere in a constructor callee expression explicitly unsupported. This includes namespace members, object properties, and numeric array indexing: the existing ArrayRef contract cannot represent arbitrary constructor property reads. Receiver and key effects are evaluated once in source order, without emitting an invalid ArrayRef. Computed access in constructor arguments remains supported.
  • Add regressions for constructor calls and locals, conditional class choice, mutation during argument evaluation, array result types, JSON/model conversion, legacy JSON, and Node.js oracle behavior.

Dependency

Stacked on JacoDB #395 (caelmbleidd/ts-390-instanceof-rhs, head b9851a0b202fbfa10a9bf0f4145ba49670b2745c), which is stacked on #397. Review this PR against #395.

Verification

  • npm run typecheck — passed.
  • npm test — 238 passed.
  • ./gradlew :jacodb-ets:test --tests org.jacodb.ets.test.EtsTsFrontendTest --no-daemon — 21 passed.
  • Node.js replay in the frontend test confirms the mutation example selects the original constructor.
  • CI run 37092594583 passed all jobs on head b5e10a1a0c5d279492c373caf907f6387fff998f. Independent pinned my-review core and hygiene passes found no actionable defects on that head.

For the local Kotlin run, the worktree's .git file required temporarily removing the Gradle git-hook stanza from settings.gradle.kts; it was restored before commit. The commit hook had the same worktree limitation and was bypassed after the checks above.

Scope

Runtime allocation and dispatch are implemented separately in UnitTestBot/usvm#466. Mutable qualified class-property constructors and computed constructor access remain explicitly unsupported by this frontend.

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

  225 files  ±0    225 suites  ±0   14m 9s ⏱️ -42s
  799 tests +3    787 ✅ +3  12 💤 ±0  0 ❌ ±0 
2 069 runs  +3  2 019 ✅ +3  50 💤 ±0  0 ❌ ±0 

Results for commit 33cd1fc. ± Comparison against base commit 03d5531.

♻️ This comment has been updated with latest results.

@CaelmBleidd
CaelmBleidd marked this pull request as ready for review October 3, 2026 06:43
@CaelmBleidd
CaelmBleidd force-pushed the caelmbleidd/ts-398-dynamic-new-ir branch from b5e10a1 to f0da474 Compare October 3, 2026 20:55
@CaelmBleidd
CaelmBleidd changed the base branch from caelmbleidd/ts-390-instanceof-rhs to caelmbleidd/ts-396-class-values October 3, 2026 20:56
@CaelmBleidd
CaelmBleidd changed the base branch from caelmbleidd/ts-396-class-values to neo October 3, 2026 20:58
@CaelmBleidd
CaelmBleidd force-pushed the caelmbleidd/ts-398-dynamic-new-ir branch from f0da474 to 33cd1fc Compare October 3, 2026 21:01
@CaelmBleidd
CaelmBleidd merged commit 454433c into neo Oct 3, 2026
7 checks passed
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