Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions internal/compatibility/generated/node-v24-backlog.json
Original file line number Diff line number Diff line change
Expand Up @@ -59405,7 +59405,8 @@
"tests/corpus/1596-cjs-modules/main.js",
"tests/corpus/1629-require-main-filename.cjs",
"tests/corpus/2830-cjs-require-self-name/main.cjs",
"tests/corpus/2880-cjs-module-graph/main.cjs"
"tests/corpus/2880-cjs-module-graph/main.cjs",
"tests/corpus/2923-cjs-factory-export/main.cjs"
]
},
"dynamic": {
Expand Down Expand Up @@ -59447,7 +59448,8 @@
"tests/corpus/1596-cjs-modules/main.js",
"tests/corpus/1629-require-main-filename.cjs",
"tests/corpus/2830-cjs-require-self-name/main.cjs",
"tests/corpus/2880-cjs-module-graph/main.cjs"
"tests/corpus/2880-cjs-module-graph/main.cjs",
"tests/corpus/2923-cjs-factory-export/main.cjs"
]
},
"dynamic": {
Expand Down Expand Up @@ -59489,7 +59491,8 @@
"tests/corpus/1596-cjs-modules/main.js",
"tests/corpus/1629-require-main-filename.cjs",
"tests/corpus/2830-cjs-require-self-name/main.cjs",
"tests/corpus/2880-cjs-module-graph/main.cjs"
"tests/corpus/2880-cjs-module-graph/main.cjs",
"tests/corpus/2923-cjs-factory-export/main.cjs"
]
},
"dynamic": {
Expand Down Expand Up @@ -59531,7 +59534,8 @@
"tests/corpus/1596-cjs-modules/main.js",
"tests/corpus/1629-require-main-filename.cjs",
"tests/corpus/2830-cjs-require-self-name/main.cjs",
"tests/corpus/2880-cjs-module-graph/main.cjs"
"tests/corpus/2880-cjs-module-graph/main.cjs",
"tests/corpus/2923-cjs-factory-export/main.cjs"
]
},
"dynamic": {
Expand Down Expand Up @@ -59609,7 +59613,8 @@
"tests/corpus/1596-cjs-modules/main.js",
"tests/corpus/1629-require-main-filename.cjs",
"tests/corpus/2830-cjs-require-self-name/main.cjs",
"tests/corpus/2880-cjs-module-graph/main.cjs"
"tests/corpus/2880-cjs-module-graph/main.cjs",
"tests/corpus/2923-cjs-factory-export/main.cjs"
]
},
"dynamic": {
Expand Down Expand Up @@ -59798,7 +59803,8 @@
"tests/corpus/1596-cjs-modules/main.js",
"tests/corpus/1629-require-main-filename.cjs",
"tests/corpus/2830-cjs-require-self-name/main.cjs",
"tests/corpus/2880-cjs-module-graph/main.cjs"
"tests/corpus/2880-cjs-module-graph/main.cjs",
"tests/corpus/2923-cjs-factory-export/main.cjs"
]
},
"dynamic": {
Expand Down Expand Up @@ -59873,7 +59879,8 @@
"tests/corpus/1596-cjs-modules/main.js",
"tests/corpus/1629-require-main-filename.cjs",
"tests/corpus/2830-cjs-require-self-name/main.cjs",
"tests/corpus/2880-cjs-module-graph/main.cjs"
"tests/corpus/2880-cjs-module-graph/main.cjs",
"tests/corpus/2923-cjs-factory-export/main.cjs"
]
},
"dynamic": {
Expand Down Expand Up @@ -59947,7 +59954,8 @@
"tests/corpus/1596-cjs-modules/main.js",
"tests/corpus/1629-require-main-filename.cjs",
"tests/corpus/2830-cjs-require-self-name/main.cjs",
"tests/corpus/2880-cjs-module-graph/main.cjs"
"tests/corpus/2880-cjs-module-graph/main.cjs",
"tests/corpus/2923-cjs-factory-export/main.cjs"
]
},
"dynamic": {
Expand Down Expand Up @@ -59989,7 +59997,8 @@
"tests/corpus/1596-cjs-modules/main.js",
"tests/corpus/1629-require-main-filename.cjs",
"tests/corpus/2830-cjs-require-self-name/main.cjs",
"tests/corpus/2880-cjs-module-graph/main.cjs"
"tests/corpus/2880-cjs-module-graph/main.cjs",
"tests/corpus/2923-cjs-factory-export/main.cjs"
]
},
"dynamic": {
Expand Down Expand Up @@ -60031,7 +60040,8 @@
"tests/corpus/1596-cjs-modules/main.js",
"tests/corpus/1629-require-main-filename.cjs",
"tests/corpus/2830-cjs-require-self-name/main.cjs",
"tests/corpus/2880-cjs-module-graph/main.cjs"
"tests/corpus/2880-cjs-module-graph/main.cjs",
"tests/corpus/2923-cjs-factory-export/main.cjs"
]
},
"dynamic": {
Expand Down
33 changes: 22 additions & 11 deletions internal/compatibility/generated/node-v24-internal.json
Original file line number Diff line number Diff line change
Expand Up @@ -73916,7 +73916,8 @@
"tests/corpus/2830-cjs-require-self-name/main.cjs",
"tests/corpus/2858-import-meta-resolve/main.mjs",
"tests/corpus/2860-require-resolve/main.cjs",
"tests/corpus/2880-cjs-module-graph/main.cjs"
"tests/corpus/2880-cjs-module-graph/main.cjs",
"tests/corpus/2923-cjs-factory-export/main.cjs"
]
},
"dynamic": {
Expand Down Expand Up @@ -73955,7 +73956,8 @@
"tests/corpus/1596-cjs-modules/main.js",
"tests/corpus/1629-require-main-filename.cjs",
"tests/corpus/2830-cjs-require-self-name/main.cjs",
"tests/corpus/2880-cjs-module-graph/main.cjs"
"tests/corpus/2880-cjs-module-graph/main.cjs",
"tests/corpus/2923-cjs-factory-export/main.cjs"
]
},
"dynamic": {
Expand Down Expand Up @@ -74020,7 +74022,8 @@
"tests/corpus/1596-cjs-modules/main.js",
"tests/corpus/1629-require-main-filename.cjs",
"tests/corpus/2830-cjs-require-self-name/main.cjs",
"tests/corpus/2880-cjs-module-graph/main.cjs"
"tests/corpus/2880-cjs-module-graph/main.cjs",
"tests/corpus/2923-cjs-factory-export/main.cjs"
]
},
"dynamic": {
Expand Down Expand Up @@ -74058,7 +74061,8 @@
"tests/corpus/1596-cjs-modules/main.js",
"tests/corpus/1629-require-main-filename.cjs",
"tests/corpus/2830-cjs-require-self-name/main.cjs",
"tests/corpus/2880-cjs-module-graph/main.cjs"
"tests/corpus/2880-cjs-module-graph/main.cjs",
"tests/corpus/2923-cjs-factory-export/main.cjs"
]
},
"dynamic": {
Expand Down Expand Up @@ -74096,7 +74100,8 @@
"tests/corpus/1596-cjs-modules/main.js",
"tests/corpus/1629-require-main-filename.cjs",
"tests/corpus/2830-cjs-require-self-name/main.cjs",
"tests/corpus/2880-cjs-module-graph/main.cjs"
"tests/corpus/2880-cjs-module-graph/main.cjs",
"tests/corpus/2923-cjs-factory-export/main.cjs"
]
},
"dynamic": {
Expand Down Expand Up @@ -74164,7 +74169,8 @@
"tests/corpus/1596-cjs-modules/main.js",
"tests/corpus/1629-require-main-filename.cjs",
"tests/corpus/2830-cjs-require-self-name/main.cjs",
"tests/corpus/2880-cjs-module-graph/main.cjs"
"tests/corpus/2880-cjs-module-graph/main.cjs",
"tests/corpus/2923-cjs-factory-export/main.cjs"
]
},
"dynamic": {
Expand Down Expand Up @@ -74331,7 +74337,8 @@
"tests/corpus/1596-cjs-modules/main.js",
"tests/corpus/1629-require-main-filename.cjs",
"tests/corpus/2830-cjs-require-self-name/main.cjs",
"tests/corpus/2880-cjs-module-graph/main.cjs"
"tests/corpus/2880-cjs-module-graph/main.cjs",
"tests/corpus/2923-cjs-factory-export/main.cjs"
]
},
"dynamic": {
Expand Down Expand Up @@ -74395,7 +74402,8 @@
"tests/corpus/1596-cjs-modules/main.js",
"tests/corpus/1629-require-main-filename.cjs",
"tests/corpus/2830-cjs-require-self-name/main.cjs",
"tests/corpus/2880-cjs-module-graph/main.cjs"
"tests/corpus/2880-cjs-module-graph/main.cjs",
"tests/corpus/2923-cjs-factory-export/main.cjs"
]
},
"dynamic": {
Expand Down Expand Up @@ -74459,7 +74467,8 @@
"tests/corpus/1596-cjs-modules/main.js",
"tests/corpus/1629-require-main-filename.cjs",
"tests/corpus/2830-cjs-require-self-name/main.cjs",
"tests/corpus/2880-cjs-module-graph/main.cjs"
"tests/corpus/2880-cjs-module-graph/main.cjs",
"tests/corpus/2923-cjs-factory-export/main.cjs"
]
},
"dynamic": {
Expand Down Expand Up @@ -74497,7 +74506,8 @@
"tests/corpus/1596-cjs-modules/main.js",
"tests/corpus/1629-require-main-filename.cjs",
"tests/corpus/2830-cjs-require-self-name/main.cjs",
"tests/corpus/2880-cjs-module-graph/main.cjs"
"tests/corpus/2880-cjs-module-graph/main.cjs",
"tests/corpus/2923-cjs-factory-export/main.cjs"
]
},
"dynamic": {
Expand Down Expand Up @@ -74535,7 +74545,8 @@
"tests/corpus/1596-cjs-modules/main.js",
"tests/corpus/1629-require-main-filename.cjs",
"tests/corpus/2830-cjs-require-self-name/main.cjs",
"tests/corpus/2880-cjs-module-graph/main.cjs"
"tests/corpus/2880-cjs-module-graph/main.cjs",
"tests/corpus/2923-cjs-factory-export/main.cjs"
]
},
"dynamic": {
Expand Down
2 changes: 1 addition & 1 deletion internal/compatibility/static-support.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
{ "chapter": "buffer", "signatures": ["`buf.readBigInt64BE([offset])`", "`buf.readBigInt64LE([offset])`", "`buf.readBigUInt64BE([offset])`", "`buf.readBigUInt64LE([offset])`", "`buf.writeBigInt64BE(value[, offset])`", "`buf.writeBigInt64LE(value[, offset])`", "`buf.writeBigUInt64BE(value[, offset])`", "`buf.writeBigUInt64LE(value[, offset])`"], "status": "supported", "evidence": ["tests/corpus/2902-bigint-bytes.ts", "tests/corpus/2904-bigint-errors.ts"] },
{ "chapter": "environment_variables", "symbols": ["export"], "status": "not-applicable" },
{ "chapter": "globals", "symbols": ["fetch"], "status": "partial", "evidence": ["tests/harness/fetch-conformance.test.ts"] },
{ "chapter": "modules", "symbols": ["__dirname", "__filename", "exports", "require", "module.require", "main", "filename"], "status": "partial", "evidence": ["tests/corpus/1612-cjs-module-globals.cjs", "tests/corpus/1596-cjs-modules/main.js", "tests/corpus/1629-require-main-filename.cjs", "tests/corpus/2830-cjs-require-self-name/main.cjs", "tests/corpus/2880-cjs-module-graph/main.cjs"] },
{ "chapter": "modules", "symbols": ["__dirname", "__filename", "exports", "require", "module.require", "main", "filename"], "status": "partial", "evidence": ["tests/corpus/1612-cjs-module-globals.cjs", "tests/corpus/1596-cjs-modules/main.js", "tests/corpus/1629-require-main-filename.cjs", "tests/corpus/2830-cjs-require-self-name/main.cjs", "tests/corpus/2880-cjs-module-graph/main.cjs", "tests/corpus/2923-cjs-factory-export/main.cjs"] },
{ "chapter": "modules", "symbols": ["require.resolve", "require.resolve.paths"], "status": "partial", "evidence": ["tests/corpus/2858-import-meta-resolve/main.mjs", "tests/corpus/2860-require-resolve/main.cjs"] },
{ "chapter": "modules", "symbols": ["cache", "children", "id", "isPreloading", "loaded", "parent", "path", "paths", "Module"], "status": "partial", "evidence": ["tests/corpus/2880-cjs-module-graph/main.cjs"] },
{ "chapter": "modules", "symbols": ["extensions"], "status": "not-implemented" },
Expand Down
5 changes: 5 additions & 0 deletions packages/compiler/src/backend/c/exprs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4351,6 +4351,11 @@ function emitDynamicLibCall(state: LibCallState): Temp {
// +1 string or NULL with the exception pending (user
// toString/valueOf throws propagate). Borrows the dyn.
return finish(`scr_dyn_string_coerce_js(${arg(0)})`);
case "dyn.toNumberCoerce":
// JS ToNumber (number-hint valueOf/toString protocol). A
// thrown hook leaves the exception pending; the may-throw
// epilogue abandons the NaN dummy.
return finish(`scr_dyn_number_coerce(${arg(0)})`);
case "global.undefRead":
// A declare-d const nothing defines: Node's catchable
// ReferenceError at the access (always throws — the typed
Expand Down
1 change: 1 addition & 0 deletions packages/compiler/src/backend/llvm/lib-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ export const LIB_FN_SYMS: Record<string, string> = {
// The checked-dynamic compare/equals validators (scr_bytes_io.c):
// Node's argument ladders throw catchably (MAY_THROW_LIB_FNS).
"dyn.toStringCoerce": "scr_dyn_string_coerce_js",
"dyn.toNumberCoerce": "scr_dyn_number_coerce",
"buffer.compareChk": "scr_buffer_compare_chk",
"bytes.equalsChk": "scr_bytes_equals_chk",
"bytes.compareChk": "scr_bytes_compare_chk",
Expand Down
13 changes: 13 additions & 0 deletions packages/compiler/src/frontend/lowering/lower-builtins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6219,6 +6219,19 @@ function lowerOptionalStringSearchParams(lowerer: Lowerer, init: IrExpr, loc: Sr
if (member !== "isTTY" && member !== "columns") return null;
let recv: ts.Expression = expr.expression;
while (ts.isParenthesizedExpression(recv) || ts.isAsExpression(recv) || ts.isTypeAssertion(recv)) recv = recv.expression;
// Browser-compatible packages commonly write
// `(process.stdout || {}).isTTY`. Node's stream object is always
// present and truthy, so the fallback cannot run; match the left
// receiver exactly as the value-level always-truthy `||` lowering
// does, preserving the native isatty/columns answer.
if (
ts.isBinaryExpression(recv) &&
recv.operatorToken.kind === ts.SyntaxKind.BarBarToken
) {
let left = recv.left;
while (ts.isParenthesizedExpression(left) || ts.isAsExpression(left) || ts.isTypeAssertion(left)) left = left.expression;
if (ts.isPropertyAccessExpression(left)) recv = left;
}
if (!ts.isPropertyAccessExpression(recv)) return null;
const stream = lowerer.stdlibGlobalMember(recv, "process");
if (stream !== "stdin" && stream !== "stdout" && stream !== "stderr") return null;
Expand Down
39 changes: 37 additions & 2 deletions packages/compiler/src/frontend/lowering/lower-calls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,22 @@ function completeFuncValueArgs(
) {
return;
}
// An uncontextualized npm-static implementation function can still
// have a declaration-backed completed ABI: the package's .d.ts
// projection supplies the body-facing parameter/return types while
// the shipped JavaScript's own inferred type remains wider (`any`
// callback fields are the common case). lambdaSignature has already
// constructed and validated that concrete ABI, and every eventual
// storage/call site independently checks it. Admit the value at birth;
// do not make the unprojected JS inference veto its authored surface.
if (
target === undefined &&
contextual !== null &&
(ts.isArrowFunction(contextual) || ts.isFunctionExpression(contextual)) &&
npmStaticPackageOfPath(contextual.getSourceFile().fileName) !== null
) {
return;
}
// An 'any'-typed slot is the ISLAND boundary: the host-function
// trampoline already implements JS call semantics over the completed
// signature — a missing engine argument arrives as undefined and takes
Expand Down Expand Up @@ -5188,8 +5204,10 @@ function lowerOptionalStringNumber(
arrayReceiver &&
((lowerer.checker.getTypeArguments(recvTs as ts.TypeReference)[0]?.flags ?? 0) &
(ts.TypeFlags.Any | ts.TypeFlags.Unknown)) !== 0;
const checkerUntyped =
(recvTs.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)) !== 0 || anyArray;
let recv: IrExpr;
if (recvTs.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown) || anyArray) {
if (checkerUntyped) {
recv = lowerer.lowerExpr(access.expression);
} else {
// A checker-TYPED spelling whose VALUE is still checked-dynamic (an
Expand Down Expand Up @@ -5272,7 +5290,24 @@ function lowerOptionalStringNumber(
// member models. Order note: JS reads the callee before evaluating
// arguments — dynKeyGet's undefined-receiver TypeError fires first,
// exactly Node.
if (DYN_PROTO_METHOD_NAMES.has(access.name.text)) return null;
// A checker-typed object whose represented value remains dyn still
// has an authored own-member contract. Let that member win even when
// its name overlaps a primitive prototype (`colors.bold(...)`): the
// source value was compiled from that object shape, while genuinely
// untyped/any receivers retain the runtime-kind ambiguity and fence.
const ownCallable = !checkerUntyped && (() => {
const prop = lowerer.checker.getPropertyOfType(recvTs, access.name.text);
if (prop === undefined) return false;
// getPropertyOfType includes inherited Object.prototype members.
// Those are not stored members of a checked-dynamic object, so
// dynKeyGet cannot stand in for JavaScript's prototype lookup. Only
// an authored declaration can justify the own-member path.
const authored = lowerer.checker.declarationsOf(prop).some(
(decl) => !lowerer.isStdlibFile(decl.getSourceFile()),
);
return authored && lowerer.checker.getCallSignatures(lowerer.checker.getTypeOfSymbol(prop)).length > 0;
})();
if (DYN_PROTO_METHOD_NAMES.has(access.name.text) && !ownCallable) return null;
// Optional forms (`obj.cb?.()`, `obj?.cb()`) belong to the chain
// machinery's short-circuit semantics — not modeled here yet.
if (call.questionDotToken || access.questionDotToken) return null;
Expand Down
Loading
Loading