@nudojs/core 2.0.0 → 2.0.1
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/dist/{chunk-VVSVQKWF.js → chunk-6REHMIAE.js} +22 -3
- package/dist/exec.js +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +35 -7
- package/package.json +1 -1
|
@@ -2811,6 +2811,15 @@ function ok() {
|
|
|
2811
2811
|
function fail(reason) {
|
|
2812
2812
|
return { ok: false, reason };
|
|
2813
2813
|
}
|
|
2814
|
+
function requiredFnArity(params) {
|
|
2815
|
+
if (!params) return 0;
|
|
2816
|
+
let n = 0;
|
|
2817
|
+
for (const p of params) {
|
|
2818
|
+
if (!p || p.startsWith("...") || p.endsWith("?")) continue;
|
|
2819
|
+
n++;
|
|
2820
|
+
}
|
|
2821
|
+
return n;
|
|
2822
|
+
}
|
|
2814
2823
|
function leqAbs(src, tgt, opts = {}) {
|
|
2815
2824
|
const phi2 = opts.phi ?? pTrue;
|
|
2816
2825
|
return leqWithPred(src, tgt, phi2, opts.env ?? null, 0);
|
|
@@ -2963,8 +2972,12 @@ function leqShape(src, tgt, phi2, env, depth) {
|
|
|
2963
2972
|
}
|
|
2964
2973
|
if (t.k === "fn") {
|
|
2965
2974
|
if (s.k !== "fn") return fail(`shape ${s.k} \u22AD fn`);
|
|
2966
|
-
|
|
2967
|
-
|
|
2975
|
+
const sReq = requiredFnArity(s.params);
|
|
2976
|
+
const tReq = requiredFnArity(t.params);
|
|
2977
|
+
if (sReq > tReq) {
|
|
2978
|
+
return fail(
|
|
2979
|
+
`fn arity required ${sReq} \u22AD target required ${tReq} (params ${s.params.length} / ${t.params.length})`
|
|
2980
|
+
);
|
|
2968
2981
|
}
|
|
2969
2982
|
if (t.returnType !== void 0) {
|
|
2970
2983
|
const sr = s.returnType;
|
|
@@ -3879,7 +3892,12 @@ function isRelFn(a) {
|
|
|
3879
3892
|
if (!s || s.k !== "fn") return false;
|
|
3880
3893
|
if (s.returnType === void 0) return false;
|
|
3881
3894
|
if (s.paramTypes === void 0) return s.params.length === 0;
|
|
3882
|
-
|
|
3895
|
+
if (s.paramTypes.length === s.params.length) return true;
|
|
3896
|
+
let required = 0;
|
|
3897
|
+
for (const p of s.params) {
|
|
3898
|
+
if (p && !p.startsWith("...") && !p.endsWith("?")) required++;
|
|
3899
|
+
}
|
|
3900
|
+
return s.paramTypes.length === required;
|
|
3883
3901
|
}
|
|
3884
3902
|
function litOfTerm(t) {
|
|
3885
3903
|
return t.op === "lit" ? t.value : void 0;
|
|
@@ -10413,6 +10431,7 @@ export {
|
|
|
10413
10431
|
awaitAbs,
|
|
10414
10432
|
coerceAsyncReturn,
|
|
10415
10433
|
classFromMethods,
|
|
10434
|
+
requiredFnArity,
|
|
10416
10435
|
leqAbs,
|
|
10417
10436
|
tagAbsOrigin,
|
|
10418
10437
|
getAbsOrigin,
|
package/dist/exec.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -490,6 +490,8 @@ type LeqResult = {
|
|
|
490
490
|
* src 可赋给 tgt。
|
|
491
491
|
* phi:路径前提(可选);env:用于 brand 继承链。
|
|
492
492
|
*/
|
|
493
|
+
/** Required arity from fn param labels — skips rest (`...`) and optional (`?`). */
|
|
494
|
+
declare function requiredFnArity(params: readonly string[] | undefined): number;
|
|
493
495
|
declare function leqAbs(src: Abs, tgt: Abs, opts?: {
|
|
494
496
|
phi?: Phi;
|
|
495
497
|
env?: AstEnv;
|
|
@@ -1793,4 +1795,4 @@ type InjectedDomainEvidenceOpts = {
|
|
|
1793
1795
|
*/
|
|
1794
1796
|
declare function checkInjectedDomainEvidence(fnName: string, source: string, records: InjectedDomainRecord[], opts: InjectedDomainEvidenceOpts): CheckIssue[];
|
|
1795
1797
|
|
|
1796
|
-
export { Abs, type AbsAssignRecord, type AbsCallRecord, type AbsFnImpl, type AbsInlay, AbsModuleExports, type AbsSigImpl, type ArgDerivation, AstEnv, type CheckIssue, type CheckJson, type CheckOptions, type CheckReport, type ClassDef, type CollectAbsInlaysOpts, Confidence, type ConstraintBuilder, type DerivationNode, type Diagnostic, type EffectiveInterface, type EffectiveInterfaceOpts, type Environment, type EvalOptions, type EvalResult, type FnAbs, type FnFp, type FormalParam, type FormatOptions, HofSite, type InjectedDomainRecord, type InterfaceDiag, type InterfaceSource, type InterfaceTierInfo, type InterfaceTierOpts, type LeakBudget, type LeqResult, type LoadDepsFingerprint, MAX_CALL_DEPTH, MAX_TOTAL_CALLS, type MethodDef, type MockHelper, type NamedImport, type NudoConstraint, type NudoField, type NudoFnConstraint, NudoSidecarError, type NudoSig, type ObjShape, Phi, type PolyFn, Pred, PrimName, type RefineDiag, type RefineEntry, type RefineResolveOpts, RelSource, SELF, Shape, type Slot, type TemplateMeta, type TemplatePartDesc, type TemplatePartView, type TemplatePredicateDecision, Term, type TypeParam, abortDerivationSession, absFunction, absShapeKey, absTemplateViews, absToConstraint, add, allFixedTextOfViews, analyzeFn, analyzeFnFull, any, applyAbsFn, array, attachFnImpl, awaitAbs, beginCollectionFork, beginDerivationSession, boolean, buildArgsFromAssume, callAbsMethod, callFunction, callFunctionFull, canSkipLiteralCallScan, checkArg, checkCall, checkInjectedDomainEvidence, checkSource, classFromMethods, clearCollectionTables, cmp, coerceAsyncReturn, collectAbsFreeVars, collectAbsInlays, collectAbsNodeTypes, collectionElementJoin, collectionExactLen, concatString, constraintToEntryAbs, contractParamNameSet, createEnvironment, createTemplateAbs, currentPhi, decideEndsWith, decideIncludes, decideStartsWith, defaultLeakBudget, defineClass, definitelyNotNullishShape, denoteGuard, derivationChain, describePhi, div, effectiveInterface, emptyEnv, endCollectionFork, endDerivationSession, errorBrandAbs, evalArrayStatic, evalBuiltinInstanceMethod, evalBuiltinNew, evalDateCtor, evalDateMethod, evalDateStatic, evalGlobalFn, evalJsonMethod, evalMathMethod, evalMethodBody, evalNamespaceCall, evalNode, evalNumberStatic, evalObjectMethod, evalProgramAbs, evalPromiseCtor, evalPromiseStatic, evalRegExpCtor, evalRegExpMethod, evalSource, evictCheckSourceMemoForPaths, evictGeneralizeMemoForPaths, exceedsBudget, execNudoModule, extractAllLoadSpecs, extractFn, extractNudoImports, extractRefineReturnFromSource, extractRefinesFromSource, falseConstraint, findAbsAtPosition, fixedLengthOfViews, fn, fnConstraintToEntryReqs, fnFingerprints, fnOf, formalParamDisplayNames, formalParamsFromNodes, formatAbs, formatAbsMultiline, formatCheckReport, formatConstraint, formatDiagnostics, formatEffectiveInterfaceDisplay, formatInterfaceTierLine, formatShape, formatShapeSlot, formatTemplateNameViews, generalizeAll, generalizeFromAst, generalizeSourceKeyPart, generatedExportNames, getAbsProperty, getClass, getClassChain, getDerivation, getFnImpl, getFnNameAndBodies, getGeneralizeMemoSize, getParseSourceCacheSize, getSlot, getTerm, hasDerivationSession, hashSource, instanceOf, instantiateClass, instantiateConstraint, interfaceDiagCount, interfaceSourceOf, interfaceTierOf, isErrorCtorName, isIntFlag, isMapAbs, isNodeModulesPath, isNudoConstraint, isNullishLitAbs, isObj, isSetAbs, isTemplateLike, joinAbs, joinFunctions, joinObjects, joinThenProject, joinValues, knownPrefixOfViews, knownSuffixOfViews, leakIfNeeded, lenTerm, leqAbs, listFunctionNames, literalMeetsConstraint, loadModuleDepsFingerprint, localNamedExports, locateContractParam, lookupMethod, lookupMethodWithOwner, lookupSuperMethod, looseEqAbs, makeMapAbs, makeSetAbs, makeSum, mapClearEntries, mapDeleteEntry, mapEntriesAbs, mapGetEntry, mapHasEntry, mapSetEntry, mapSizeAbs, mapValuesAbs, matchRelIdentLit, maybeLeak, mergeAdjacentFixedViews, mergeCollectionArms, mock, mod, mul, negAbs, normPath, notAbs, noteCollectionWrite, noteDerivationAdd, noteDerivationJoin, number, objOf, omit, parseSource, partial, pick, popCollectionArm, popPhi, projectBrand, projectDerivationDsl, pushCollectionArm, pushPhi, refineAbsForRelTrue, refineDiagCount, refineToIndexedFull, relationFingerprint, relationFn, resetAbsCallBudget, resetCheckSourceMemo, resetFnFpCache, resetGeneralizeMemo, resetHashSourceCache, resetLeakCounter, resetNudoModuleExecCache, resetParseSourceCache, resetPhi, resolveDepPath, serializeCheckJson, setAbsAssignCollector, setAbsCallCollector, setAbsNodeCollector, setAbsTruncationCollector, setAddEntry, setClearEntries, setDeleteEntry, setDerivation, setDerivationCollector, setElementsAbs, setHasEntry, setInterfaceDiagCollector, setRefineDiagCollector, setSizeAbs, shape, shapeOnlyFn, sidecarClosureFingerprint, sidecarPathOf, sidecarSpecsOf, spread, spy, stableAnalyzeKeySource, strictEqAbs, string, stripTypes, stub, sub, superNameOf, tagDerivationRoot, takeInterfaceDiags, takeInterfaceDiagsSince, takeRefineDiags, takeRefineDiagsSince, templateMatchesValue, templatePartsOf, termDepth, termKey, termNodes, trueConstraint, typeofAbs, union, viewTemplateParts, withPhiConstraint, withVar, wrapPromise };
|
|
1798
|
+
export { Abs, type AbsAssignRecord, type AbsCallRecord, type AbsFnImpl, type AbsInlay, AbsModuleExports, type AbsSigImpl, type ArgDerivation, AstEnv, type CheckIssue, type CheckJson, type CheckOptions, type CheckReport, type ClassDef, type CollectAbsInlaysOpts, Confidence, type ConstraintBuilder, type DerivationNode, type Diagnostic, type EffectiveInterface, type EffectiveInterfaceOpts, type Environment, type EvalOptions, type EvalResult, type FnAbs, type FnFp, type FormalParam, type FormatOptions, HofSite, type InjectedDomainRecord, type InterfaceDiag, type InterfaceSource, type InterfaceTierInfo, type InterfaceTierOpts, type LeakBudget, type LeqResult, type LoadDepsFingerprint, MAX_CALL_DEPTH, MAX_TOTAL_CALLS, type MethodDef, type MockHelper, type NamedImport, type NudoConstraint, type NudoField, type NudoFnConstraint, NudoSidecarError, type NudoSig, type ObjShape, Phi, type PolyFn, Pred, PrimName, type RefineDiag, type RefineEntry, type RefineResolveOpts, RelSource, SELF, Shape, type Slot, type TemplateMeta, type TemplatePartDesc, type TemplatePartView, type TemplatePredicateDecision, Term, type TypeParam, abortDerivationSession, absFunction, absShapeKey, absTemplateViews, absToConstraint, add, allFixedTextOfViews, analyzeFn, analyzeFnFull, any, applyAbsFn, array, attachFnImpl, awaitAbs, beginCollectionFork, beginDerivationSession, boolean, buildArgsFromAssume, callAbsMethod, callFunction, callFunctionFull, canSkipLiteralCallScan, checkArg, checkCall, checkInjectedDomainEvidence, checkSource, classFromMethods, clearCollectionTables, cmp, coerceAsyncReturn, collectAbsFreeVars, collectAbsInlays, collectAbsNodeTypes, collectionElementJoin, collectionExactLen, concatString, constraintToEntryAbs, contractParamNameSet, createEnvironment, createTemplateAbs, currentPhi, decideEndsWith, decideIncludes, decideStartsWith, defaultLeakBudget, defineClass, definitelyNotNullishShape, denoteGuard, derivationChain, describePhi, div, effectiveInterface, emptyEnv, endCollectionFork, endDerivationSession, errorBrandAbs, evalArrayStatic, evalBuiltinInstanceMethod, evalBuiltinNew, evalDateCtor, evalDateMethod, evalDateStatic, evalGlobalFn, evalJsonMethod, evalMathMethod, evalMethodBody, evalNamespaceCall, evalNode, evalNumberStatic, evalObjectMethod, evalProgramAbs, evalPromiseCtor, evalPromiseStatic, evalRegExpCtor, evalRegExpMethod, evalSource, evictCheckSourceMemoForPaths, evictGeneralizeMemoForPaths, exceedsBudget, execNudoModule, extractAllLoadSpecs, extractFn, extractNudoImports, extractRefineReturnFromSource, extractRefinesFromSource, falseConstraint, findAbsAtPosition, fixedLengthOfViews, fn, fnConstraintToEntryReqs, fnFingerprints, fnOf, formalParamDisplayNames, formalParamsFromNodes, formatAbs, formatAbsMultiline, formatCheckReport, formatConstraint, formatDiagnostics, formatEffectiveInterfaceDisplay, formatInterfaceTierLine, formatShape, formatShapeSlot, formatTemplateNameViews, generalizeAll, generalizeFromAst, generalizeSourceKeyPart, generatedExportNames, getAbsProperty, getClass, getClassChain, getDerivation, getFnImpl, getFnNameAndBodies, getGeneralizeMemoSize, getParseSourceCacheSize, getSlot, getTerm, hasDerivationSession, hashSource, instanceOf, instantiateClass, instantiateConstraint, interfaceDiagCount, interfaceSourceOf, interfaceTierOf, isErrorCtorName, isIntFlag, isMapAbs, isNodeModulesPath, isNudoConstraint, isNullishLitAbs, isObj, isSetAbs, isTemplateLike, joinAbs, joinFunctions, joinObjects, joinThenProject, joinValues, knownPrefixOfViews, knownSuffixOfViews, leakIfNeeded, lenTerm, leqAbs, listFunctionNames, literalMeetsConstraint, loadModuleDepsFingerprint, localNamedExports, locateContractParam, lookupMethod, lookupMethodWithOwner, lookupSuperMethod, looseEqAbs, makeMapAbs, makeSetAbs, makeSum, mapClearEntries, mapDeleteEntry, mapEntriesAbs, mapGetEntry, mapHasEntry, mapSetEntry, mapSizeAbs, mapValuesAbs, matchRelIdentLit, maybeLeak, mergeAdjacentFixedViews, mergeCollectionArms, mock, mod, mul, negAbs, normPath, notAbs, noteCollectionWrite, noteDerivationAdd, noteDerivationJoin, number, objOf, omit, parseSource, partial, pick, popCollectionArm, popPhi, projectBrand, projectDerivationDsl, pushCollectionArm, pushPhi, refineAbsForRelTrue, refineDiagCount, refineToIndexedFull, relationFingerprint, relationFn, requiredFnArity, resetAbsCallBudget, resetCheckSourceMemo, resetFnFpCache, resetGeneralizeMemo, resetHashSourceCache, resetLeakCounter, resetNudoModuleExecCache, resetParseSourceCache, resetPhi, resolveDepPath, serializeCheckJson, setAbsAssignCollector, setAbsCallCollector, setAbsNodeCollector, setAbsTruncationCollector, setAddEntry, setClearEntries, setDeleteEntry, setDerivation, setDerivationCollector, setElementsAbs, setHasEntry, setInterfaceDiagCollector, setRefineDiagCollector, setSizeAbs, shape, shapeOnlyFn, sidecarClosureFingerprint, sidecarPathOf, sidecarSpecsOf, spread, spy, stableAnalyzeKeySource, strictEqAbs, string, stripTypes, stub, sub, superNameOf, tagDerivationRoot, takeInterfaceDiags, takeInterfaceDiagsSince, takeRefineDiags, takeRefineDiagsSince, templateMatchesValue, templatePartsOf, termDepth, termKey, termNodes, trueConstraint, typeofAbs, union, viewTemplateParts, withPhiConstraint, withVar, wrapPromise };
|
package/dist/index.js
CHANGED
|
@@ -272,6 +272,7 @@ import {
|
|
|
272
272
|
registerBClass,
|
|
273
273
|
relationFingerprint,
|
|
274
274
|
relationFn,
|
|
275
|
+
requiredFnArity,
|
|
275
276
|
resetAbsCallBudget,
|
|
276
277
|
resetLeakCounter,
|
|
277
278
|
resetParseSourceCache,
|
|
@@ -337,7 +338,7 @@ import {
|
|
|
337
338
|
withExecPhi,
|
|
338
339
|
withVar,
|
|
339
340
|
wrapPromise
|
|
340
|
-
} from "./chunk-
|
|
341
|
+
} from "./chunk-6REHMIAE.js";
|
|
341
342
|
|
|
342
343
|
// src/environment.ts
|
|
343
344
|
function createEnvironment(parent, bindings = /* @__PURE__ */ new Map()) {
|
|
@@ -511,13 +512,39 @@ function formatShape(a) {
|
|
|
511
512
|
case "tuple":
|
|
512
513
|
return `[${s.elements.map(formatShape).join(", ")}]`;
|
|
513
514
|
case "fn": {
|
|
514
|
-
if (s.paramTypes && s.paramTypes.length > 0) {
|
|
515
|
-
const ps = s.paramTypes.map((p) => formatShapeSlot(p));
|
|
516
|
-
const ret2 = s.returnType !== void 0 ? formatShapeSlot(s.returnType) : "?";
|
|
517
|
-
return `(${ps.join(", ")}) => ${ret2}`;
|
|
518
|
-
}
|
|
519
515
|
const ret = s.returnType !== void 0 ? formatShapeSlot(s.returnType) : "?";
|
|
520
|
-
|
|
516
|
+
const labels = s.params ?? [];
|
|
517
|
+
const paramTypes = s.paramTypes;
|
|
518
|
+
const hasMarkers = labels.some(
|
|
519
|
+
(p) => p.startsWith("...") || p.endsWith("?")
|
|
520
|
+
);
|
|
521
|
+
const renderLabeled = () => {
|
|
522
|
+
const ps = [];
|
|
523
|
+
const n = paramTypes ? Math.max(paramTypes.length, labels.length) : labels.length;
|
|
524
|
+
for (let i = 0; i < n; i++) {
|
|
525
|
+
const label = labels[i];
|
|
526
|
+
const type = paramTypes?.[i];
|
|
527
|
+
const typeText = type !== void 0 ? formatShapeSlot(type) : void 0;
|
|
528
|
+
if (label?.startsWith("...")) {
|
|
529
|
+
ps.push(typeText ? `...${label.slice(3)}: ${typeText}` : label);
|
|
530
|
+
} else if (label?.endsWith("?")) {
|
|
531
|
+
ps.push(typeText ? `${label.slice(0, -1)}?: ${typeText}` : label);
|
|
532
|
+
} else if (typeText !== void 0) {
|
|
533
|
+
ps.push(typeText);
|
|
534
|
+
} else if (label) {
|
|
535
|
+
ps.push(label);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
return ps;
|
|
539
|
+
};
|
|
540
|
+
if (hasMarkers) {
|
|
541
|
+
return `(${renderLabeled().join(", ")}) => ${ret}`;
|
|
542
|
+
}
|
|
543
|
+
if (paramTypes && paramTypes.length > 0) {
|
|
544
|
+
const ps = paramTypes.map((p) => formatShapeSlot(p));
|
|
545
|
+
return `(${ps.join(", ")}) => ${ret}`;
|
|
546
|
+
}
|
|
547
|
+
return `(${labels.join(", ")}) => ${ret}`;
|
|
521
548
|
}
|
|
522
549
|
case "brand":
|
|
523
550
|
return `${s.name}`;
|
|
@@ -6695,6 +6722,7 @@ export {
|
|
|
6695
6722
|
registerBClass,
|
|
6696
6723
|
relationFingerprint,
|
|
6697
6724
|
relationFn,
|
|
6725
|
+
requiredFnArity,
|
|
6698
6726
|
resetAbsCallBudget,
|
|
6699
6727
|
resetCheckSourceMemo,
|
|
6700
6728
|
resetFnFpCache,
|