mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-23 06:10:02 +08:00
The npm case fixtures lost their only native test with the native-only compilation change. tests/harness/npm.test.ts runs every case again with the default static npm compile and compares it with Node. A KNOWN table records the cases the compile refuses (with the diagnostic code), the cases whose run reaches a deferred refusal (the code in the program's output), and the two that still diverge, which run as expected failures. The suite joins the case-sharded CI corpus files. Fixes from the run: - A package imported only by subpath (`pkg/env.js` from a package with no "main", "exports" or index file) was refused as having no runtime entry. Eligibility now resolves the imported specifier when the root has none. - diagnostics_channel: a throwing subscriber stopped publish, and a throwing bindStore transform stopped runStores. Node runs the remaining subscribers, skips that store, and reports each error as uncaught on a next tick; the runtime now does the same. - A '#' import that the package's "imports" field maps to another package failed at run time with Node's "not defined" error, which Node does not raise. It is now a compile-time SC1010 refusal. - An uncaught runtime refusal whose code is an SC code now names the code. - Mapping a type in the optional array-element analysis could lower an unsupported local class and let its PoisonError escape as a compiler crash; the analysis now treats that element ABI as unknown, so the program fails with the recorded diagnostic. - A lexical module binding initialized from an unchecked array element holding a function failed validation (SC9001): its widened storage was a union, which a TDZ guard cannot hold. Such bindings now keep checked-value storage and their guard. - A dynamically reached ArrayBuffer had no constructor property.
7 lines
369 B
JavaScript
7 lines
369 B
JavaScript
// A dynamically reached ArrayBuffer answers constructor with the global
|
|
// ArrayBuffer, as typed arrays answer theirs.
|
|
const items = [new Uint8Array(2), new ArrayBuffer(3), new Float32Array(1)];
|
|
for (const item of items) console.log(item.constructor.name, item.constructor === ArrayBuffer);
|
|
const b = new ArrayBuffer(4);
|
|
console.log(b.constructor.name, b.byteLength);
|