SC9001 ICE: varRef type object != binding dyn on bundled circular module-level consts
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 52/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript, node.js, typescript
調査の方向性
Start by reading the compiler’s handling of module-level const bindings, returned closures, and varRef type validation; the issue does not name source files or tests for these paths. Reproduce with the 12-line JavaScript example using scriptc build, then compare it with the controls that compile. Done when the bundled JavaScript builds successfully and its runtime output remains 1.
索引モデルが issue の本文から書いたものです。
説明
Summary
scriptc build hits SC9001 (internal compiler error: varRef "…" type object != binding dyn) on legal JavaScript that bundlers emit: a module-level const closes over another module-level const that is initialized later by a factory returning new SomeClass(...).
scriptc coverage of the same file is 100% static. Node runs it. The identical program as TypeScript compiles. So this is a codegen/IR-validation ICE, not a coverage or language-service crash.
Reduced from rolldown-bundled effect/Schema (t3code vp pack chunk Schema-CHz9fEw2.mjs, four ICEs at the Go-nil codec consts nullAsMissing / nullAsEmptyArray / emptyRecord / nullAsEmptyRecord). Please do not ask applications to unminify that chunk by hand — the 12-line program below is sufficient.
Reproduction
repro.mjs:
class Box {
constructor(v) {
this.v = v;
}
}
function apply(f) {
return f;
}
const earlier = apply(() => later);
const make = (v) => new Box(v);
const later = make(1);
console.log(earlier().v);
$ node repro.mjs
1
$ scriptc coverage repro.mjs
# 6/6 statements static (100%)
$ scriptc build repro.mjs -o out
repro.mjs:9:29 - error SC9001: internal compiler error: in %fn.309985bfdfc6: varRef "%g.e.later" type object != binding dyn — please report this
8 | }
9 | const earlier = apply(() => later);
| ^~~~~
10 | const make = (v) => new Box(v);
1 error.
Minified to one line, same ICE:
class Box{constructor(v){this.v=v}}function apply(f){return f}const earlier=apply(ast=>later),make=v=>new Box(v),later=make(1);console.log(earlier(0).v)
apply can be the identity (return f). What matters is that the closing lambda is returned from a call, not assigned directly.
Controls that compile and print 1
Same program as TypeScript (repro.ts with a typed apply / make) — scriptc build succeeds.
Reordering so later is initialized first:
const make = (v) => new Box(v);
const later = make(1);
const earlier = apply(() => later);
Direct new instead of a factory (still a circular const):
const earlier = apply(() => later);
const later = new Box(1);
Unbundled modules (the factory and later in a second file, imported by the closer) also compile. That is why unminified npm effect source (scriptc build entry.mjs --npm-static=effect) succeeds while a rolldown bundle of the same library fails.
Original trigger
scriptc build of a rolldown bundle of [email protected] Schema (pretty-printed, original names kept) reports four ICEs, all this pattern:
Schema.unmin.mjs:12937:39 - error SC9001: … varRef "%g.e.nullAsMissing" type object != binding dyn
Schema.unmin.mjs:12941:144 - error SC9001: … varRef "%g.e.nullAsEmptyArray" type object != binding dyn
Schema.unmin.mjs:12942:139 - error SC9001: … varRef "%g.e.emptyRecord" type object != binding dyn
Schema.unmin.mjs:12942:165 - error SC9001: … varRef "%g.e.nullAsEmptyRecord" type object != binding dyn
Those names are module-level consts in effect/src/internal/schema/toCodec.ts:
const nilAsMissingAtEncoded = applyToSelfOrLastLinkEncoding((ast) => {
return orNull(ast, decodeNull(never, nullAsMissing));
});
const nilAsEmptyAtEncoded = applyToSelfOrLastLinkEncoding((ast) => {
// …
return orNull(ast, decodeNull(replaceChecks(emptyRecord, ast.checks), nullAsEmptyRecord));
});
const nullTo = (decode) => new Transformation(decode, forbidden(() => "…"));
const nullAsMissing = nullTo(transformOptional(() => none()));
const nullAsEmptyArray = nullTo(transform(() => []));
const nullAsEmptyRecord = nullTo(transform(() => ({})));
const emptyRecord = record(string, never);
Circular module-level consts through a helper that only stores the callback are legal JS (const TDZ is not hit because applyToSelfOrLastLinkEncoding does not call f during init). Rolldown concatenates them into one module; scriptc then types the binding as dyn and the varRef as object.
Workaround for consumers
Compile TypeScript / npm source (ordinary per-file modules), not bundler output. t3code will feed scriptc build src/binMain.ts rather than vp pack chunks for this reason. That is a consumer dodge, not a fix.
Environment
- scriptc 0.4.17 and 0.4.16 (identical ICE on the 12-line repro; not a 0.4.17 regression)
@scriptc/cli-linux-x64-gnu, Node.js 24.13.1, linux x64- effect 4.1.5 for the original Schema bundle; the reduced repro has no dependencies
Relationship to existing reports
Searched open and closed SC9001 / ICE issues (varRef, binding dyn, emptyRecord, nullAsMissing, minified circular consts). Closest hits are other SC9001 shapes (recordKeyGet, bytesSet, toString protocol) — none are varRef type object vs binding dyn. Distinct from #4381 (tsc-ts SIGSEGV on one large file) and from #4171 (coverage abort on @effect/platform-node).
- 主要言語
- 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 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 58/100
vercel-labs/scriptc#4864 ·
メンテナーはふだん 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 日以内に返信
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 日以内に返信