[TS] Construct project class instances from runtime constructor values

已關閉
#465 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
5/5
預估耗時
一週以上
新手友好度
38/100
Issue 類型
功能
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
kotlin, node.js, typescript

研究方向

Start by tracing how the TypeScript symbolic executor allocates new expressions and how JacoDB EtsIR represents evaluated constructor operands, with dependency UnitTestBot/jacodb#398 in view. Add a focused symbolic test covering both classes, constructor identity, evaluation order, and unsupported values, then replay generated inputs and results in Node.js. Done means direct construction and existing instanceof behavior still pass, while unsupported and failed cases remain distinct.

由索引模型根據 Issue 內容生成。

描述

Problem

The TypeScript symbolic executor allocates new expressions by an EtsIR class type. That cannot execute new through an evaluated constructor value: a variable or call may choose between classes with the same static type. The JacoDB frontend currently marks this form unsupported while its EtsIR representation is being extended.

Minimal TypeScript example

class A { value: number; constructor(value: number) { this.value = value; } }
class B { value: number; constructor(value: number) { this.value = value; } }

function choose(useA: boolean): typeof A | typeof B {
  return useA ? A : B;
}

export function check(useA: boolean): boolean {
  const value = new (choose(useA))(7);
  return value instanceof A && value.value === 7;
}

Node.js returns true for check(true) and false for check(false).

Expected support

Consume the evaluated constructor operand from JacoDB EtsIR and allocate an instance of the selected project class. Invoke that class's constructor once with the evaluated arguments; preserve callee-before-arguments order and constructor identity across calls and local aliases. Keep unknown or symbolic constructor identities explicitly unsupported until they have a sound model. A non-constructable value must not silently allocate an instance.

Acceptance criteria

  • A focused symbolic test obtains both outcomes from one static constructor-union type, with unsupported and failures reported separately.
  • Generated concrete inputs and results replay in Node.js, including a constructor returned by another function and an argument that mutates the constructor variable after the callee has been selected.
  • Direct new A() and existing instanceof behavior remain correct.

Dependency: UnitTestBot/jacodb#398. Related: JacoDB #396 for declared class runtime values and USVM #457 for runtime instanceof.

主要語言
Kotlin
星號
33
分支
28
平均合併
2 天 19 小時
30 天內合併 PR
76

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

UnitTestBot/usvm 的其他 Issue

查看 UnitTestBot/usvm 的全部 Issue

相似的 Issue

更多 Kotlin Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。