mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-01 07:33:12 +08:00
Expect the map and record-width results the PR's lowering now gives
This commit is contained in:
@@ -58,7 +58,7 @@ export {};
|
||||
expect(validateModule(result.module)).toEqual([]);
|
||||
});
|
||||
|
||||
test("a void-returning map callback still has no element to store", async () => {
|
||||
test("a void-returning map callback stores undefined elements", async () => {
|
||||
const result = await lower(`
|
||||
const items = [1, 2];
|
||||
const out = items.map((n) => {
|
||||
@@ -67,8 +67,8 @@ const out = items.map((n) => {
|
||||
console.log(out.length);
|
||||
export {};
|
||||
`);
|
||||
// `void[]` stays unrepresentable: a void value is erased before it could
|
||||
// be written. Only the CLOSURE element became an ordinary element.
|
||||
expect(result.ok).toBe(false);
|
||||
if (!result.ok) expect(result.codes).toEqual(["SC2009"]);
|
||||
// A discarding mapper's answer is undefined, which the result array
|
||||
// stores as its element (as Node's map does).
|
||||
if (!result.ok) throw new Error(`fenced: ${result.codes.join(", ")}`);
|
||||
expect(validateModule(result.module)).toEqual([]);
|
||||
});
|
||||
|
||||
@@ -7,15 +7,6 @@ record-width.ts:12:25 - error SC2002: record shapes must match exactly or width-
|
||||
|
||||
hint: width subtyping compiles as a copy (each expected field copied off the source; extra fields drop) — this pair is outside the copy's rules; build a literal with exactly the expected fields instead
|
||||
|
||||
record-width.ts:26:20 - error SC2002: record shapes must match exactly or width-coerce: expected '{ m: ({ a: number; b: number }) => void }', got '{ extra: number; m: ({ a: number }) => void }' — field 'm': '({ a: number }) => void' does not lift into '({ a: number; b: number }) => void'
|
||||
|
||||
25 | };
|
||||
26 | const dstM: DstM = srcM;
|
||||
| ^~~~
|
||||
27 | console.log(dstM);
|
||||
|
||||
hint: width subtyping compiles as a copy (each expected field copied off the source; extra fields drop) — this pair is outside the copy's rules; build a literal with exactly the expected fields instead
|
||||
|
||||
record-width.ts:27:13 - error SC1090: console.log of '{ m: ({ a: number; b: number }) => void }' values (function values have no inspect lowering (no runtime name exists — Node prints '[Function: name]'; pass the function's declared identifier directly to util.inspect for the baked form)) is not supported yet
|
||||
|
||||
26 | const dstM: DstM = srcM;
|
||||
|
||||
Reference in New Issue
Block a user