A generic class instantiated with two types reads the second instance as the first, natively (regressed in 0.4.16)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 58/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- node.js, typescript
- 領域
- compilers
調査の方向性
Start by reproducing the failure from the issue’s gm6.js example with allowJs, checkJs, and strict enabled; compare native output with the Node.js and scriptc 0.4.12 results. The issue points to packages/light/native/probes/p-g4-generic-composition.js as another reproducer. Trace how the compiler handles the two Lazy specializations and confirm the fix by getting both examples to print 42 ab without diagnostics.
索引モデルが issue の本文から書いたものです。
説明
A generic class instantiated with a number and then with a string miscompiles the second instance natively, with no diagnostic. It builds 100% static and throws at run time. It regressed between 0.4.12 and 0.4.16 and is still in 0.5.0.
Reproduction
gm6.js, built with a tsconfig that has allowJs, checkJs and strict (so the JSDoc types reach the compiler):
/** @template T */
class Lazy {
/** @param {() => T} fn */
constructor(fn) {
this._fn = fn;
/** @type {T} */
this._value = fn();
}
/** @param {T} value */
_assign(value) {
this._value = value;
}
/** @returns {T} */
get value() {
this._assign(this._fn());
return this._value;
}
}
const n = new Lazy(() => 42);
const s = new Lazy(() => "ab");
console.log(n.value, s.value);
| Build | Output | Exit | |
|---|---|---|---|
| Node.js v25.3.0 | 42 ab |
0 | |
| scriptc 0.4.12 | no diagnostics | 42 ab |
0 |
| scriptc 0.4.16 | no diagnostics | Uncaught TypeError: expected number at $, got string |
1 |
| scriptc 0.5.0 | no diagnostics | Uncaught TypeError: expected number at $, got string |
1 |
Without checkJs all three releases print 42 ab. The two instantiations of Lazy seem to share one specialization, so the string instance is read as a number.
Environment
Linux x86_64, glibc 2.39, scriptc's linux-x64-gnu packages from npm.
Found through light's probe packages/light/native/probes/p-g4-generic-composition.js, which fails the same way.
- 主要言語
- TypeScript
- スター
- 6.7k
- フォーク
- 229
- 平均マージ
- 14時間 29分
- マージ済み PR(30日)
- 787
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
vercel-labs/scriptc のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 58/100
vercel-labs/scriptc#4865 ·
メンテナーはふだん 1 日以内に返信
-
Windows ARM64 as a cross-compile target対応中かも @hum-n が 1 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
vercel-labs/scriptc#4858 ·
メンテナーはふだん 1 日以内に返信
-
post-merge-bisect-unresolved
難易度 3/5 1〜2日 初心者へのやさしさ 43/100
vercel-labs/scriptc#4791 ·
メンテナーはふだん 1 日以内に返信
-
post-merge-bisect-unconfirmed
難易度 5/5 1週間以上 初心者へのやさしさ 12/100
vercel-labs/scriptc#4755 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
vercel-labs/scriptc#4634 ·
メンテナーはふだん 1 日以内に返信
vercel-labs/scriptc の issue をすべて見る
似ている issue
-
bug data-types
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
ClickHouse/clickhouse-js#1293 ·
メンテナーはふだん 1 日以内に返信
-
area: middleware enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
agent/quality testing
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 92/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
juspay/agent-distro#203 ·
メンテナーはふだん 1 日以内に返信