mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-24 06:14:01 +08:00
- Extract preflight's benign-cycle admission (the cheap per-edge rule plus the declaration-only init window analysis, with Tarjan SCC and cluster-verdict memos) into makeCycleAdmission; preflight's static walk and appendDynamicImportModules now judge back edges identically, so benign cycles behind dynamic import() compile as Node cache hits instead of blanket SC1016. - appendDynamicImportModules runs once in lowerToIr before any pass constructs: the old per-constructor run minted cycle refusals into the discovery pass, whose diagnostics are discarded by design, so inadmissible import() cycles silently compiled; refusals now land on the emit pass with the same narrowed reason (binding and line, or the offending top-level statement) the static walk mints. - SC1016 gains a registry hint naming the admitted shape and the fix; diagnostics snapshots, order-parity baselines, and the surface manifest repin with it. - Corpus 2604 (mutual class cycle across two modules), 2605 (three-module function ring with two back edges and a function-body-only value use), 2606 (import() into an admitted mutual-recursion cycle) — all byte-identical to Node through both backends; diagnostics fixture dyn-import-cycle-tdz pins the dynamic-path TDZ refusal.
11 lines
449 B
TypeScript
11 lines
449 B
TypeScript
// A THREE-module import ring (a → b → c → a) of mutually-recursive
|
|
// functions. Every module's top level is declaration-only and each
|
|
// cycle-crossing binding is only called inside a function body, so the
|
|
// whole ring is admitted; Node evaluates c, b, a, main and the guarded
|
|
// %init calls reproduce that order exactly.
|
|
import { hop } from "./b.ts";
|
|
|
|
export function start(n: number): string {
|
|
return n <= 0 ? "!" : "a" + hop(n - 1);
|
|
}
|