@scriptc/compiler 0.0.10 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ambient/scriptc-node-fallback.d.ts +63 -15
- package/ambient/scriptc.d.ts +2 -2
- package/dist/backend/cc.d.ts +2 -2
- package/dist/backend/emission/emit-async.js +1 -1
- package/dist/backend/emission/emit-exprs.js +131 -54
- package/dist/backend/emission/emit-exprs.js.map +1 -1
- package/dist/backend/emission/emit-island.js +1 -1
- package/dist/backend/emission/emit-shapes.js +1 -1
- package/dist/backend/emission/emit-walkers.d.ts +14 -14
- package/dist/backend/emission/emit-walkers.js +44 -44
- package/dist/backend/emission/emit-walkers.js.map +1 -1
- package/dist/backend/emission/emitter.d.ts +3 -3
- package/dist/backend/emission/emitter.js +33 -9
- package/dist/backend/emission/emitter.js.map +1 -1
- package/dist/backend/emission/may-throw.js +1 -1
- package/dist/backend/llvm/dyn.d.ts +10 -10
- package/dist/backend/llvm/dyn.js +26 -26
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.js +156 -47
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/shapes.js +1 -1
- package/dist/backend/llvm/walkers.js +2 -2
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/coverage/surface-manifest.js +16 -2
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +21 -8
- package/dist/diagnostics/diagnostic.js +48 -14
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/frontend/lowering/lib-boundary.js +5 -5
- package/dist/frontend/lowering/lib-boundary.js.map +1 -1
- package/dist/frontend/lowering/lower-assert.js +12 -12
- package/dist/frontend/lowering/lower-assert.js.map +1 -1
- package/dist/frontend/lowering/lower-builtins.d.ts +63 -7
- package/dist/frontend/lowering/lower-builtins.js +327 -35
- package/dist/frontend/lowering/lower-builtins.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +4 -4
- package/dist/frontend/lowering/lower-calls.js +104 -70
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +7 -0
- package/dist/frontend/lowering/lower-classes.js +82 -6
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-containers.d.ts +9 -5
- package/dist/frontend/lowering/lower-containers.js +88 -26
- package/dist/frontend/lowering/lower-containers.js.map +1 -1
- package/dist/frontend/lowering/lower-emitter.d.ts +70 -3
- package/dist/frontend/lowering/lower-emitter.js +438 -31
- package/dist/frontend/lowering/lower-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +87 -12
- package/dist/frontend/lowering/lower-exprs.js +630 -125
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.js +5 -5
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-island.js +12 -3
- package/dist/frontend/lowering/lower-island.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.d.ts +8 -5
- package/dist/frontend/lowering/lower-modules.js +157 -63
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-namespaces.d.ts +24 -0
- package/dist/frontend/lowering/lower-namespaces.js +158 -16
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
- package/dist/frontend/lowering/lower-server.js +11 -11
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +1 -1
- package/dist/frontend/lowering/lower-stmts.js +271 -36
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.js +171 -20
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +27 -10
- package/dist/frontend/lowering/lowerer.js +156 -54
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/surfaces.d.ts +44 -0
- package/dist/frontend/lowering/surfaces.js +236 -5
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/npm.d.ts +12 -0
- package/dist/frontend/npm.js +30 -0
- package/dist/frontend/npm.js.map +1 -1
- package/dist/frontend/program.d.ts +25 -0
- package/dist/frontend/program.js +145 -136
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/shared.d.ts +1 -1
- package/dist/frontend/shared.js +8 -8
- package/dist/frontend/shared.js.map +1 -1
- package/dist/frontend/types.d.ts +2 -2
- package/dist/frontend/types.js +15 -15
- package/dist/frontend/types.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +169 -5
- package/dist/index.js.map +1 -1
- package/dist/ir/nodes.d.ts +174 -106
- package/dist/ir/nodes.js +69 -24
- package/dist/ir/nodes.js.map +1 -1
- package/dist/ir/validate.js +55 -36
- package/dist/ir/validate.js.map +1 -1
- package/dist/library/fence-eval.js +12 -2
- package/dist/library/fence-eval.js.map +1 -1
- package/dist/library/int-infer.d.ts +119 -0
- package/dist/library/int-infer.js +1314 -0
- package/dist/library/int-infer.js.map +1 -0
- package/dist/library/int-infer.test.d.ts +1 -0
- package/dist/library/int-infer.test.js +279 -0
- package/dist/library/int-infer.test.js.map +1 -0
- package/dist/library/profile.d.ts +34 -5
- package/dist/library/profile.js +77 -13
- package/dist/library/profile.js.map +1 -1
- package/dist/library/sidecar-validate.js +1 -1
- package/dist/library/sidecar-validate.js.map +1 -1
- package/dist/library/sidecar.d.ts +24 -1
- package/dist/library/sidecar.js +163 -16
- package/dist/library/sidecar.js.map +1 -1
- package/package.json +2 -2
- package/surface-manifest.json +210 -12
|
@@ -344,6 +344,10 @@ export declare function lowerBytesNew(L: Lowerer, expr: ts.NewExpression, symbol
|
|
|
344
344
|
* else the lib declares (fill, indexOf, reverse, ...) falls through to
|
|
345
345
|
* the SC2020 member fence. Null when this isn't a bytes method call. */
|
|
346
346
|
export declare function lowerBytesMethodCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression): IrExpr | null;
|
|
347
|
+
/** A literal encoding's canonical name, or undefined for a spelling Node
|
|
348
|
+
* does not know — the ladder callers (stream options) turn unknown
|
|
349
|
+
* literals into Node's runtime ERR_UNKNOWN_ENCODING throw. */
|
|
350
|
+
export declare function knownBufEncoding(name: string): string | undefined;
|
|
347
351
|
/** The literal encoding argument of a Buffer surface, normalized — or a
|
|
348
352
|
* fence when it isn't a literal alias Node knows. */
|
|
349
353
|
export declare function bufEncoding(L: Lowerer, what: string, encNode: ts.Expression): string;
|
|
@@ -362,7 +366,7 @@ export declare function lowerBufferStaticCall(L: Lowerer, call: ts.CallExpressio
|
|
|
362
366
|
* result order is Node-exact; hybrids inherit the documented
|
|
363
367
|
* declared-then-overflow divergence. Values surface as the checker's
|
|
364
368
|
* result element type: identity, an arm-into-union wrap, or (dyn
|
|
365
|
-
* results) the
|
|
369
|
+
* results) the dyn conversion — recordKeyGet's own surfacing rules for
|
|
366
370
|
* the overflow, mirrored statically for declared fields. */
|
|
367
371
|
export declare function lowerObjectIterOverIndexShape(L: Lowerer, call: ts.CallExpression, member: "keys" | "values" | "entries", argIr: IrType & {
|
|
368
372
|
kind: "record";
|
|
@@ -481,9 +485,9 @@ export declare function lowerEnvToPairsHelper(L: Lowerer, shapeId: string, loc:
|
|
|
481
485
|
/** The validated-STRING extraction of a dyn method receiver — the receiver
|
|
482
486
|
* expression the string/regex method lowerings consume. */
|
|
483
487
|
export declare function dynStringReceiver(L: Lowerer, recv: IrExpr, access: ts.PropertyAccessExpression): IrExpr;
|
|
484
|
-
/** `d.filter(pred)` on a dyn receiver: the receiver must BE a
|
|
488
|
+
/** `d.filter(pred)` on a dyn receiver: the receiver must BE a dyn array
|
|
485
489
|
* (else the Node-shaped TypeError above); the predicate runs per element
|
|
486
|
-
* over the
|
|
490
|
+
* over the dyn value, and each SURVIVOR is validated-extracted into the
|
|
487
491
|
* result's element type T — the type the checker already committed the
|
|
488
492
|
* call to (the contextual `RouteMapping[]`/`string[]` slot). Extraction is
|
|
489
493
|
* the checked-cast machinery: a survivor that doesn't fit T throws the
|
|
@@ -494,9 +498,9 @@ export declare function dynStringReceiver(L: Lowerer, recv: IrExpr, access: ts.P
|
|
|
494
498
|
export declare function lowerDynArrayFilterCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression, recv: IrExpr): IrExpr | null;
|
|
495
499
|
/** `.flatMap(f)` on a dyn ('unknown'/`any[]`-narrowed) receiver where the
|
|
496
500
|
* callback returns a STATIC array (`parsed.flatMap((v) => typeof v ===
|
|
497
|
-
* "string" ? parseTldList(v) : [])` — the tlds-file shape): the
|
|
501
|
+
* "string" ? parseTldList(v) : [])` — the tlds-file shape): the checked-dynamic tree
|
|
498
502
|
* array walks element-by-element, the callback sees each element as the
|
|
499
|
-
*
|
|
503
|
+
* dyn value `unknown` code sees, and its typed results concatenate —
|
|
500
504
|
* depth-1 flatten by construction, no validation needed on the results
|
|
501
505
|
* (they are already typed; only the RECEIVER is dynamic). Non-array
|
|
502
506
|
* receivers throw the Node-shaped TypeError. Callbacks returning
|
|
@@ -65,11 +65,11 @@ export function lowerArrayMethodCall(L, call, access) {
|
|
|
65
65
|
const result = { kind: "jsOp", op: "callMethod", name, args: [receiver, ...args], type: JSVAL, loc };
|
|
66
66
|
return islandPrimitiveExit(L, call, result);
|
|
67
67
|
}
|
|
68
|
-
// An array-mapped CHECKER type whose VALUE lives in the
|
|
69
|
-
// (`Object.keys(dynObj).sort()` — the key-walk answers a
|
|
68
|
+
// An array-mapped CHECKER type whose VALUE lives in the checked-dynamic tree
|
|
69
|
+
// (`Object.keys(dynObj).sort()` — the key-walk answers a dyn array):
|
|
70
70
|
// the record family's array sibling. Methods with a runtime
|
|
71
71
|
// receiver-kind dispatch ride dynInvoke — the real method runs on
|
|
72
|
-
// the
|
|
72
|
+
// the dyn array, JS-exact; the rest keep an honest fence instead of
|
|
73
73
|
// handing a static array intrinsic a dyn receiver (the validator
|
|
74
74
|
// ICE). Consumers validate the dyn result where a static type is
|
|
75
75
|
// required (dynCheck — the member-read discipline).
|
|
@@ -336,7 +336,7 @@ function hofCallbackArg(L, argNode, lead, arrT) {
|
|
|
336
336
|
// A DYN-receiver HOF's callback (`parsed.flatMap((value) => ...)`):
|
|
337
337
|
// the contextual signature types the unannotated param `any` (the
|
|
338
338
|
// receiver is checker-`any[]`), while the VALUE each call receives is
|
|
339
|
-
// the
|
|
339
|
+
// the dyn element `unknown` code sees — narrow the param declaration
|
|
340
340
|
// to `unknown` so it lowers as the dyn it carries (typeof tests and
|
|
341
341
|
// validated extractions ride as usual) instead of fencing on `any`.
|
|
342
342
|
const overridden = [];
|
|
@@ -4004,9 +4004,26 @@ export function lowerRegexMethodCall(L, call, access, dynReceiver) {
|
|
|
4004
4004
|
// [whole match, ...captures] or the null arm. The g-flag match returns
|
|
4005
4005
|
// EVERY match (a different shape) and /y is stateful — both fence at
|
|
4006
4006
|
// compile time on literal arguments (values reaching the runtime with
|
|
4007
|
-
// those flags abort, the test() stance). `.index`/`.input
|
|
4008
|
-
//
|
|
4009
|
-
|
|
4007
|
+
// those flags abort, the test() stance). `.index`/`.input` reads on
|
|
4008
|
+
// the result fence per member (array-typed value); `.groups` reads
|
|
4009
|
+
// desugar at their access sites when the regex is statically known
|
|
4010
|
+
// (lowerMatchGroupsRead).
|
|
4011
|
+
// `s.match(re)` also claims a NULLABLE string receiver (string + unit
|
|
4012
|
+
// arms — `process.versions.openssl.match(...)`, the Dict<string>
|
|
4013
|
+
// member the node suite's crypto helper reads): the checked
|
|
4014
|
+
// extraction narrows to the string arm and a unit value throws the
|
|
4015
|
+
// catchable TypeError at the read, where Node's own member read
|
|
4016
|
+
// throws — tsc only admits the spelling in JS sources.
|
|
4017
|
+
const nullableStringRecv = receiverKind === "union" &&
|
|
4018
|
+
name === "match" &&
|
|
4019
|
+
(() => {
|
|
4020
|
+
const t = L.mapTypeOf(L.typeOf(access.expression));
|
|
4021
|
+
if (t?.kind !== "union")
|
|
4022
|
+
return false;
|
|
4023
|
+
const arms = L.unions.get(t.unionId)?.arms ?? [];
|
|
4024
|
+
return arms.some((a) => a.kind === "string") && arms.every((a) => a.kind === "string" || isUnitType(a));
|
|
4025
|
+
})();
|
|
4026
|
+
if ((receiverKind === "string" || nullableStringRecv) && name === "match") {
|
|
4010
4027
|
const arg0 = call.arguments[0];
|
|
4011
4028
|
if (!arg0 || L.mapTypeOf(L.typeOf(arg0))?.kind !== "regex")
|
|
4012
4029
|
return null; // string-pattern match: the SC2020 fence
|
|
@@ -4021,7 +4038,7 @@ export function lowerRegexMethodCall(L, call, access, dynReceiver) {
|
|
|
4021
4038
|
L.unsupported("SC1120", call, "'.match()' with the 'g' or 'y' flag (an every-match array is a different shape — use replaceAll/split, or test() per position)");
|
|
4022
4039
|
}
|
|
4023
4040
|
}
|
|
4024
|
-
const receiver = lowerReceiver();
|
|
4041
|
+
const receiver = nullableStringRecv ? L.lowerExprExpecting(access.expression, STRING) : lowerReceiver();
|
|
4025
4042
|
const re = L.lowerExpr(arg0);
|
|
4026
4043
|
// RegExpMatchArray | null maps to the string[] | null union by
|
|
4027
4044
|
// itself; intern it directly when the checker's spelling doesn't —
|
|
@@ -4116,7 +4133,7 @@ export function lowerStringMethodCall(L, call, access, dynReceiver) {
|
|
|
4116
4133
|
return null;
|
|
4117
4134
|
// A validated dyn receiver (`pkg.name.replace(...)` on a JSON.parse
|
|
4118
4135
|
// value) arrives pre-extracted through `dynReceiver`; its checker type
|
|
4119
|
-
// is `any`, so the type/symbol gates don't apply — the
|
|
4136
|
+
// is `any`, so the type/symbol gates don't apply — the dyn value's
|
|
4120
4137
|
// methods can only BE the string intrinsics.
|
|
4121
4138
|
if (dynReceiver === undefined) {
|
|
4122
4139
|
const receiverIr = L.mapTypeOf(L.typeOf(access.expression));
|
|
@@ -4395,8 +4412,30 @@ export function lowerBytesMethodCall(L, call, access) {
|
|
|
4395
4412
|
}
|
|
4396
4413
|
const receiver = L.lowerExpr(access.expression);
|
|
4397
4414
|
const args = call.arguments.map((a) => L.lowerExprExpecting(a, F64));
|
|
4398
|
-
// subarray
|
|
4399
|
-
|
|
4415
|
+
// subarray is a VIEW (TypedArray.prototype.subarray aliases), and
|
|
4416
|
+
// Buffer's slice() is subarray's deprecated Node alias — resolved by
|
|
4417
|
+
// where the member is declared, the toString discipline below. Only
|
|
4418
|
+
// the plain typed arrays' slice() copies (JS-exact).
|
|
4419
|
+
const declaredOnBuffer = name === "slice" &&
|
|
4420
|
+
(() => {
|
|
4421
|
+
const nameSym = L.checker.getSymbolAtLocation(access.name);
|
|
4422
|
+
return nameSym !== undefined && L.checker.declarationsOf(nameSym).some((d) => ts.isInterfaceDeclaration(d.parent) && d.parent.name.text === "Buffer");
|
|
4423
|
+
})();
|
|
4424
|
+
const method = name === "subarray" || declaredOnBuffer ? "subarray" : "slice";
|
|
4425
|
+
return { kind: "bytesIntrinsic", method, receiver, args, type: receiverIr, loc };
|
|
4426
|
+
}
|
|
4427
|
+
if (name === "fill" && receiverIr.elem !== "u8") {
|
|
4428
|
+
// TypedArray.prototype.fill on the non-u8 kinds: per-element value
|
|
4429
|
+
// coercion, slice-clamped relative indices, never throws. u8
|
|
4430
|
+
// receivers keep the Buffer fill family (string patterns, throwing
|
|
4431
|
+
// offset validation) — lowerBufferInstanceMethod's surface.
|
|
4432
|
+
if (nArgs < 1 || nArgs > 3) {
|
|
4433
|
+
L.noLowering(`.fill with ${nArgs} arguments on typed arrays`, call);
|
|
4434
|
+
}
|
|
4435
|
+
const receiver = L.lowerExpr(access.expression);
|
|
4436
|
+
const v = L.lowerExprExpecting(call.arguments[0], F64);
|
|
4437
|
+
const idx = call.arguments.slice(1).map((a) => L.lowerExprExpecting(a, F64));
|
|
4438
|
+
return { kind: "bytesIntrinsic", method: "fillElem", receiver, args: [v, ...idx], type: receiverIr, loc };
|
|
4400
4439
|
}
|
|
4401
4440
|
if (name === "set") {
|
|
4402
4441
|
if (nArgs < 1 || nArgs > 2) {
|
|
@@ -4571,6 +4610,12 @@ const BUF_ENCODINGS = {
|
|
|
4571
4610
|
ucs2: "utf16le",
|
|
4572
4611
|
"ucs-2": "utf16le",
|
|
4573
4612
|
};
|
|
4613
|
+
/** A literal encoding's canonical name, or undefined for a spelling Node
|
|
4614
|
+
* does not know — the ladder callers (stream options) turn unknown
|
|
4615
|
+
* literals into Node's runtime ERR_UNKNOWN_ENCODING throw. */
|
|
4616
|
+
export function knownBufEncoding(name) {
|
|
4617
|
+
return own(BUF_ENCODINGS, name);
|
|
4618
|
+
}
|
|
4574
4619
|
/** The literal encoding argument of a Buffer surface, normalized — or a
|
|
4575
4620
|
* fence when it isn't a literal alias Node knows. */
|
|
4576
4621
|
export function bufEncoding(L, what, encNode) {
|
|
@@ -4646,7 +4691,7 @@ function lowerBufferInstanceMethod(L, call, access, name, loc) {
|
|
|
4646
4691
|
// literals) wrap in dynFrom, `undefined` literals ride the same wrap.
|
|
4647
4692
|
// Fences (never returns) when the value cannot cross — an island jsval.
|
|
4648
4693
|
const chkArg = (i) => {
|
|
4649
|
-
// Object literals take the
|
|
4694
|
+
// Object literals take the dyn literal path directly (method members
|
|
4650
4695
|
// box as dyn functions — the typed record fence never applies).
|
|
4651
4696
|
if (ts.isObjectLiteralExpression(args[i])) {
|
|
4652
4697
|
return lowerDynObjectLiteral(L, args[i]);
|
|
@@ -4853,6 +4898,22 @@ export function lowerBufferStaticCall(L, call, access) {
|
|
|
4853
4898
|
const loc = locOf(call);
|
|
4854
4899
|
const args = call.arguments;
|
|
4855
4900
|
if (member === "from") {
|
|
4901
|
+
// Buffer.from(x.buffer[, byteOffset[, length]]): a u8 VIEW sharing
|
|
4902
|
+
// x's storage (Node shares the ArrayBuffer; length is in BYTES).
|
|
4903
|
+
// The first argument must be the SYNTACTIC `.buffer` of a typed
|
|
4904
|
+
// array — the DataView peel — and the construction rides the same
|
|
4905
|
+
// dataViewNew intrinsic (offset/length validation throws Node's
|
|
4906
|
+
// DataView-shaped RangeErrors; valid indices behave exactly).
|
|
4907
|
+
if (args.length >= 1 && args.length <= 3 && !args.some(ts.isSpreadElement) &&
|
|
4908
|
+
ts.isPropertyAccessExpression(args[0]) && args[0].name.text === "buffer") {
|
|
4909
|
+
const srcNode = args[0].expression;
|
|
4910
|
+
const srcIr = L.mapTypeOf(L.typeOf(srcNode));
|
|
4911
|
+
if (srcIr?.kind === "bytes") {
|
|
4912
|
+
const receiver = L.lowerExpr(srcNode);
|
|
4913
|
+
const idxArgs = args.slice(1).map((a) => L.lowerExprExpecting(a, F64));
|
|
4914
|
+
return { kind: "bytesIntrinsic", method: "dataViewNew", receiver, args: idxArgs, type: BYTES_U8, loc };
|
|
4915
|
+
}
|
|
4916
|
+
}
|
|
4856
4917
|
if (args.length >= 1 && args.length <= 2 && !ts.isSpreadElement(args[0])) {
|
|
4857
4918
|
const argNode = args[0];
|
|
4858
4919
|
if (ts.isArrayLiteralExpression(argNode) && !argNode.elements.some(ts.isSpreadElement)) {
|
|
@@ -4882,7 +4943,8 @@ export function lowerBufferStaticCall(L, call, access) {
|
|
|
4882
4943
|
}
|
|
4883
4944
|
}
|
|
4884
4945
|
L.noLowering("Buffer.from with this argument shape", call, "supported: Buffer.from(string, encoding?) with a literal encoding, Buffer.from(u8Array) — a copy — " +
|
|
4885
|
-
"
|
|
4946
|
+
"Buffer.from(number[]), or Buffer.from(x.buffer, byteOffset?, length?) — a view sharing x's " +
|
|
4947
|
+
"storage (no free-standing ArrayBuffer value exists; narrow unions first)");
|
|
4886
4948
|
}
|
|
4887
4949
|
if (member === "alloc" || member === "allocUnsafe") {
|
|
4888
4950
|
const maxArgs = member === "alloc" ? 3 : 1;
|
|
@@ -5025,7 +5087,7 @@ export function lowerBufferStaticCall(L, call, access) {
|
|
|
5025
5087
|
* result order is Node-exact; hybrids inherit the documented
|
|
5026
5088
|
* declared-then-overflow divergence. Values surface as the checker's
|
|
5027
5089
|
* result element type: identity, an arm-into-union wrap, or (dyn
|
|
5028
|
-
* results) the
|
|
5090
|
+
* results) the dyn conversion — recordKeyGet's own surfacing rules for
|
|
5029
5091
|
* the overflow, mirrored statically for declared fields. */
|
|
5030
5092
|
export function lowerObjectIterOverIndexShape(L, call, member, argIr, shape) {
|
|
5031
5093
|
const resultT = L.irTypeOf(call);
|
|
@@ -5538,7 +5600,7 @@ export function lowerRecordOvfCaptureHelper(L, fromId, toId, loc) {
|
|
|
5538
5600
|
// target also declares. Non-dyn slots store THROUGH on a collision, so
|
|
5539
5601
|
// such writes need every declared field to BE the slot type (the
|
|
5540
5602
|
// validator's recordKeySet rule); dyn slots validate per field
|
|
5541
|
-
// (dynCheck), so each field must be
|
|
5603
|
+
// (dynCheck), so each field must be dyn-convertible. Writes to
|
|
5542
5604
|
// literal names the target does NOT declare are overflowOnly and
|
|
5543
5605
|
// exempt — which is what lets a direct-initialized required field
|
|
5544
5606
|
// (`id: number` beside a `number | undefined` slot) coexist with a
|
|
@@ -6284,7 +6346,7 @@ export function lowerEnvToPairsHelper(L, shapeId, loc) {
|
|
|
6284
6346
|
}
|
|
6285
6347
|
/* ── dyn METHOD receivers ──────────────────────────────────────────────────
|
|
6286
6348
|
* Method calls on `unknown`/JSON.parse-derived receivers (`pkg.name
|
|
6287
|
-
* .replace(...)`, `ws.packages.filter(...)`): validate the receiver's
|
|
6349
|
+
* .replace(...)`, `ws.packages.filter(...)`): validate the receiver's dyn
|
|
6288
6350
|
* kind, extract, then ride the STATIC method machinery — the dyn boundary's
|
|
6289
6351
|
* trust-but-VERIFY stance extended to receivers. A receiver of the wrong
|
|
6290
6352
|
* kind throws the catchable Node-shaped TypeError V8 would ("x.replace is
|
|
@@ -6387,9 +6449,9 @@ export function dynStringReceiver(L, recv, access) {
|
|
|
6387
6449
|
loc,
|
|
6388
6450
|
};
|
|
6389
6451
|
}
|
|
6390
|
-
/** `d.filter(pred)` on a dyn receiver: the receiver must BE a
|
|
6452
|
+
/** `d.filter(pred)` on a dyn receiver: the receiver must BE a dyn array
|
|
6391
6453
|
* (else the Node-shaped TypeError above); the predicate runs per element
|
|
6392
|
-
* over the
|
|
6454
|
+
* over the dyn value, and each SURVIVOR is validated-extracted into the
|
|
6393
6455
|
* result's element type T — the type the checker already committed the
|
|
6394
6456
|
* call to (the contextual `RouteMapping[]`/`string[]` slot). Extraction is
|
|
6395
6457
|
* the checked-cast machinery: a survivor that doesn't fit T throws the
|
|
@@ -6427,8 +6489,8 @@ export function lowerDynArrayFilterCall(L, call, access, recv) {
|
|
|
6427
6489
|
if (!elemT || !L.jsonSafe(elemT)) {
|
|
6428
6490
|
// No JSON-representable destination (`const failed = checks.filter(
|
|
6429
6491
|
// fn)` in untyped JS — test/common's runCallChecks): the result
|
|
6430
|
-
// STAYS in the
|
|
6431
|
-
// runs the real filter over the
|
|
6492
|
+
// STAYS in the checked-dynamic tree — the runtime prototype dispatch (scr_dyn_invoke)
|
|
6493
|
+
// runs the real filter over the dyn array and the survivors keep
|
|
6432
6494
|
// their dyn selves, no extraction needed. The typed-destination path
|
|
6433
6495
|
// above stays preferred: it hands back a real T[].
|
|
6434
6496
|
return null;
|
|
@@ -6452,9 +6514,9 @@ export function lowerDynArrayFilterCall(L, call, access, recv) {
|
|
|
6452
6514
|
}
|
|
6453
6515
|
/** `.flatMap(f)` on a dyn ('unknown'/`any[]`-narrowed) receiver where the
|
|
6454
6516
|
* callback returns a STATIC array (`parsed.flatMap((v) => typeof v ===
|
|
6455
|
-
* "string" ? parseTldList(v) : [])` — the tlds-file shape): the
|
|
6517
|
+
* "string" ? parseTldList(v) : [])` — the tlds-file shape): the checked-dynamic tree
|
|
6456
6518
|
* array walks element-by-element, the callback sees each element as the
|
|
6457
|
-
*
|
|
6519
|
+
* dyn value `unknown` code sees, and its typed results concatenate —
|
|
6458
6520
|
* depth-1 flatten by construction, no validation needed on the results
|
|
6459
6521
|
* (they are already typed; only the RECEIVER is dynamic). Non-array
|
|
6460
6522
|
* receivers throw the Node-shaped TypeError. Callbacks returning
|
|
@@ -6470,10 +6532,10 @@ export function lowerDynArrayFlatMapCall(L, call, access, recv) {
|
|
|
6470
6532
|
if (ret.kind !== "array") {
|
|
6471
6533
|
// A DYNAMIC-returning callback (`plugins.flatMap((plugin) =>
|
|
6472
6534
|
// plugin.languages ?? [])` — the getSupportInfo shape, where the
|
|
6473
|
-
// callback's members ride the
|
|
6535
|
+
// callback's members ride the checked-dynamic tree): the call dispatches on the
|
|
6474
6536
|
// RECEIVER's runtime kind (dynInvoke) with the callback boxed —
|
|
6475
6537
|
// a wrapped ISLAND receiver runs the ENGINE's own JS-exact
|
|
6476
|
-
// Array.prototype.flatMap (the routed-ops lane), a native
|
|
6538
|
+
// Array.prototype.flatMap (the routed-ops lane), a native dyn
|
|
6477
6539
|
// array runs the runtime's flatMap, and non-arrays throw Node's
|
|
6478
6540
|
// TypeError. The result stays dyn, checked per use.
|
|
6479
6541
|
if (ret.kind === "dyn" || ret.kind === "jsval") {
|
|
@@ -6643,10 +6705,10 @@ function dynFilterHelper(L, elemT, arity, loc) {
|
|
|
6643
6705
|
}
|
|
6644
6706
|
/** out = []; n = d.length; for (i..n) { v = d[i]; if (f(v, i, d)) out.push(
|
|
6645
6707
|
* check<T>(v)); } return out; — with the receiver-kind gate up front. The
|
|
6646
|
-
* length reads ONCE (the
|
|
6708
|
+
* length reads ONCE (the checked-dynamic tree is immutable under the static surface), the
|
|
6647
6709
|
* element reads through the canonical-index keyed read, the callback gets
|
|
6648
6710
|
* whatever prefix of (element, index, receiver) it declares — the element
|
|
6649
|
-
* and receiver as
|
|
6711
|
+
* and receiver as dyn values, exactly what `unknown` code sees. */
|
|
6650
6712
|
function buildDynFilterFn(name, elemT, arity, loc) {
|
|
6651
6713
|
const outT = arrayOf(elemT);
|
|
6652
6714
|
const fnT = funcOf([DYN, F64, DYN].slice(0, arity), BOOL);
|