[TS] Audit and formalize the type relations used by usvm-ts
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 30/100
- issue の種類
- リファクタリング
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- kotlin, node.js, typescript
- 領域
- compilers, devtools, testing-qa
調査の方向性
Start by mapping the consumers of TsTypeSystem operations, including UTypeRegion and USupportTypeStream, and classify the required relations. Use the TypeScript compiler API for static checks and Node.js for runtime predicates. Done means a checked-in design note, consumer map, executable conformance and property tests, documented unsupported cases, and focused follow-up issues for defects.
索引モデルが issue の本文から書いたものです。
説明
Execution scope and priority
The first deliverable is the consumer/relation map, laws and focused executable checks for type operations actually used by the current engine. Implement independent semantic fixes in focused follow-ups; do not combine a complete TypeScript type system, generic type framework and all engine changes into one PR.
Preserve conservative handling of uncertainty: UNKNOWN/unsupported is not semantic false and must not silently prune feasible alternatives. Static assignability, runtime membership and abstract-domain order may require distinct relations, but add APIs only for demonstrated consumers.
This broad audit is not a blanket blocker for #345/#360. If a concrete defect affects a selected experiment or built-in applicability, create a minimal regression/fix issue and block that affected task. Keep the full investigation checklist below as the audit scope, not a demand to implement unsupported language features before any experiment can run.
Context
PR #344 exposed a semantic coupling in the current TypeScript type implementation. TsTypeSystem.isSupertype is used by the symbolic type-constraint machinery, but related type decisions also affect structural property access, virtual call target selection, and runtime checks such as instanceof.
These operations do not necessarily use the same relation:
- TypeScript assignability is primarily structural and depends on compiler options;
instanceoffollows the JavaScript runtime prototype chain;- property reads and writes require a structural shape/capability constraint;
UTypeRegionneeds a coherent order and auxiliary operations for pruning symbolic type alternatives.
The fix in #344 introduces an internal nominal wrapper for instanceof so that a runtime hierarchy check does not change the established EtsAuxiliaryType behavior. This fixes the observed regression, but it also shows that the boundaries and laws of the type model are not yet explicit. TsTypeSystem is still marked as a draft, and several cases are unsupported or handled by provisional rules.
Problem
We need to establish which type relations USVM for TypeScript actually requires, formalize them, and verify that every consumer uses the appropriate relation.
The audit should cover at least:
- the intended meaning of
EtsAuxiliaryTypeand whether it is a TypeScript structural type, an abstract-domain constraint such as “has these properties”, or both; - nominal class hierarchy versus structural compatibility;
any,unknown,never,null, andundefined, including the assumedstrictNullChecksmode;- literal and primitive types;
- unions and intersections;
- arrays and tuples;
- function types and variance;
- classes, interfaces, unclear reference types, aliases, and synthetic structural types;
- coherence of
isSupertype,hasCommonSubtype,isFinal,isInstantiable,findSubtypes, andtopTypeStreamwith the expectations ofUTypeRegionandUSupportTypeStream.
Some current rules are candidates for errors, but should be checked against the chosen semantics rather than changed independently. Examples include intersection subtyping, bidirectional relations between auxiliary and class types, treatment of unknown with nullish types, and whether findSubtypes returns direct successors as required by UTypeSystem.
Proposed work
- Map the consumers. List every use of the type-system operations and classify it as static assignability, runtime membership/prototype testing, structural capability checking, call dispatch, or abstract-domain ordering.
- Specify the relations. Define the supported type universe, normalization rules, compiler-option assumptions, and the meaning of each public operation. State the laws required by the constraint engine, such as reflexivity/transitivity where applicable and coherence between subtype checks, common-subtype checks, finality, and subtype enumeration.
- Build an executable conformance matrix. Cover every supported pair/family of types and explicitly record unsupported cases and conservative fallbacks.
- Add independent oracles. Compare static assignability cases with the TypeScript compiler API under the selected compiler options. Check runtime predicates such as
instanceofwith JavaScript/Node.js examples instead of deriving them from static assignability. - Add property-based/metamorphic tests. Generate small type graphs and validate the stated laws and
UTypeRegionpruning behavior. Keep minimal counterexamples for every discovered violation. - Separate relations where necessary. If one API cannot represent the required semantics without ambiguity, introduce explicit operations or typed wrappers rather than encoding the distinction through accidental call-site conventions.
- Fix discovered defects in focused follow-up changes. Classify every known deviation as a sound over-approximation, an under-approximation, or an implementation bug.
Deliverables / acceptance criteria
- A checked-in design note defining the supported TypeScript and runtime type semantics and the assumptions made about compiler options.
- A consumer map showing which relation each analysis operation requires.
- An executable test matrix covering all currently supported
EtsTypefamilies. - Differential tests against the TypeScript compiler for static assignability and against Node.js for runtime type predicates.
- Property tests for the laws relied upon by
UTypeRegion/USupportTypeStream. - Minimal regression tests for every defect found during the audit.
- Unsupported or intentionally approximate cases are documented and handled conservatively.
- Follow-up implementation issues/PRs are split by independently reviewable semantic change.
Non-goal
This issue does not require implementing the entire TypeScript type system at once. Advanced features that are not represented by the current IR may remain unsupported, but their behavior must be explicit and must not silently make the symbolic type constraints unsound.
- 主要言語
- Kotlin
- スター
- 33
- フォーク
- 27
- 平均マージ
- 4日 3時間
- マージ済み PR(30日)
- 15
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
UnitTestBot/usvm のほかの issue
-
難易度 5/5 1週間以上 初心者へのやさしさ 45/100
UnitTestBot/usvm#388 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
UnitTestBot/usvm#384 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
UnitTestBot/usvm#382 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
UnitTestBot/usvm#379 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
UnitTestBot/usvm#373 ·
UnitTestBot/usvm の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
index-request triaged
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Anthonyy232/Paperize#614 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
bitcoindevkit/bdk-ffi#1125 ·
-
🌑 nextgen
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
CCBlueX/LiquidBounce#9214 · コメント 1 件 ·