@nudojs/core 1.9.3 → 1.9.4
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-HD6XZFOU.js → chunk-PGTNSUTE.js} +60 -11
- package/dist/{chunk-VMGJYMIF.js → chunk-S7HJL5GW.js} +74 -27
- package/dist/exec.js +1 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +19 -14
- package/dist/internal.js +2 -2
- package/package.json +1 -1
|
@@ -4612,7 +4612,12 @@ var NudoUnsupportedError = class extends Error {
|
|
|
4612
4612
|
};
|
|
4613
4613
|
|
|
4614
4614
|
// src/algebra/param-surface.ts
|
|
4615
|
-
function
|
|
4615
|
+
function pushNestedPath(prefix, key, nestedPaths) {
|
|
4616
|
+
if (prefix.length === 0 || !key) return;
|
|
4617
|
+
if (key.includes(".") || prefix.some((seg) => seg.includes("."))) return;
|
|
4618
|
+
nestedPaths.push([...prefix, key].join("."));
|
|
4619
|
+
}
|
|
4620
|
+
function collectPatternNames(p, top, nested, depth, propKey, prefix, nestedPaths) {
|
|
4616
4621
|
if (!p) return;
|
|
4617
4622
|
if (p.type === "Identifier" && p.name) {
|
|
4618
4623
|
if (depth === 0) top.push(p.name);
|
|
@@ -4620,17 +4625,17 @@ function collectPatternNames(p, top, nested, depth, propKey) {
|
|
|
4620
4625
|
return;
|
|
4621
4626
|
}
|
|
4622
4627
|
if (p.type === "AssignmentPattern") {
|
|
4623
|
-
collectPatternNames(p.left, top, nested, depth, propKey);
|
|
4628
|
+
collectPatternNames(p.left, top, nested, depth, propKey, prefix, nestedPaths);
|
|
4624
4629
|
return;
|
|
4625
4630
|
}
|
|
4626
4631
|
if (p.type === "RestElement") {
|
|
4627
|
-
collectPatternNames(p.argument, top, nested, depth, propKey);
|
|
4632
|
+
collectPatternNames(p.argument, top, nested, depth, propKey, prefix, nestedPaths);
|
|
4628
4633
|
return;
|
|
4629
4634
|
}
|
|
4630
4635
|
if (p.type === "ObjectPattern") {
|
|
4631
4636
|
for (const prop of p.properties ?? []) {
|
|
4632
4637
|
if (prop.type === "RestElement" || prop.argument) {
|
|
4633
|
-
collectPatternNames(prop.argument, top, nested, depth, propKey);
|
|
4638
|
+
collectPatternNames(prop.argument, top, nested, depth, propKey, prefix, nestedPaths);
|
|
4634
4639
|
continue;
|
|
4635
4640
|
}
|
|
4636
4641
|
const keyName = prop.key?.type === "Identifier" && prop.key.name ? prop.key.name : prop.key && "value" in prop.key ? String(prop.key.value ?? "") : void 0;
|
|
@@ -4642,7 +4647,17 @@ function collectPatternNames(p, top, nested, depth, propKey) {
|
|
|
4642
4647
|
else nested.push(keyName);
|
|
4643
4648
|
if (propKey && depth === 0) propKey[keyName] = keyName;
|
|
4644
4649
|
}
|
|
4650
|
+
const patternValueKeyRule = () => {
|
|
4651
|
+
if (!keyName) return;
|
|
4652
|
+
if (depth === 0 && prefix.length === 0) {
|
|
4653
|
+
top.push(keyName);
|
|
4654
|
+
if (propKey) propKey[keyName] = keyName;
|
|
4655
|
+
} else {
|
|
4656
|
+
pushNestedPath(prefix, keyName, nestedPaths);
|
|
4657
|
+
}
|
|
4658
|
+
};
|
|
4645
4659
|
if (v2.type === "Identifier" && v2.name) {
|
|
4660
|
+
pushNestedPath(prefix, keyName ?? "", nestedPaths);
|
|
4646
4661
|
if (depth === 0) {
|
|
4647
4662
|
top.push(v2.name);
|
|
4648
4663
|
if (propKey && keyName) propKey[v2.name] = keyName;
|
|
@@ -4650,15 +4665,38 @@ function collectPatternNames(p, top, nested, depth, propKey) {
|
|
|
4650
4665
|
} else if (v2.type === "AssignmentPattern") {
|
|
4651
4666
|
const left = v2.left;
|
|
4652
4667
|
if (left?.type === "Identifier" && left.name) {
|
|
4668
|
+
pushNestedPath(prefix, keyName ?? "", nestedPaths);
|
|
4653
4669
|
if (depth === 0) {
|
|
4654
4670
|
top.push(left.name);
|
|
4655
4671
|
if (propKey && keyName) propKey[left.name] = keyName;
|
|
4656
4672
|
} else nested.push(left.name);
|
|
4673
|
+
} else if (left && (left.type === "ObjectPattern" || left.type === "ArrayPattern")) {
|
|
4674
|
+
patternValueKeyRule();
|
|
4675
|
+
collectPatternNames(
|
|
4676
|
+
v2,
|
|
4677
|
+
top,
|
|
4678
|
+
nested,
|
|
4679
|
+
depth,
|
|
4680
|
+
propKey,
|
|
4681
|
+
prefix.concat(keyName ? [keyName] : []),
|
|
4682
|
+
nestedPaths
|
|
4683
|
+
);
|
|
4657
4684
|
} else {
|
|
4658
|
-
collectPatternNames(v2, top, nested, depth, propKey);
|
|
4685
|
+
collectPatternNames(v2, top, nested, depth, propKey, prefix, nestedPaths);
|
|
4659
4686
|
}
|
|
4687
|
+
} else if (v2.type === "ObjectPattern" || v2.type === "ArrayPattern") {
|
|
4688
|
+
patternValueKeyRule();
|
|
4689
|
+
collectPatternNames(
|
|
4690
|
+
v2,
|
|
4691
|
+
top,
|
|
4692
|
+
nested,
|
|
4693
|
+
depth + 1,
|
|
4694
|
+
propKey,
|
|
4695
|
+
prefix.concat(keyName ? [keyName] : []),
|
|
4696
|
+
nestedPaths
|
|
4697
|
+
);
|
|
4660
4698
|
} else {
|
|
4661
|
-
collectPatternNames(v2, top, nested, depth + 1, propKey);
|
|
4699
|
+
collectPatternNames(v2, top, nested, depth + 1, propKey, prefix, nestedPaths);
|
|
4662
4700
|
}
|
|
4663
4701
|
}
|
|
4664
4702
|
return;
|
|
@@ -4670,9 +4708,9 @@ function collectPatternNames(p, top, nested, depth, propKey) {
|
|
|
4670
4708
|
if (depth === 0) top.push(el.name);
|
|
4671
4709
|
else nested.push(el.name);
|
|
4672
4710
|
} else if (el.type === "AssignmentPattern") {
|
|
4673
|
-
collectPatternNames(el, top, nested, depth, propKey);
|
|
4711
|
+
collectPatternNames(el, top, nested, depth, propKey, [], nestedPaths);
|
|
4674
4712
|
} else {
|
|
4675
|
-
collectPatternNames(el, top, nested, depth + 1, propKey);
|
|
4713
|
+
collectPatternNames(el, top, nested, depth + 1, propKey, [], nestedPaths);
|
|
4676
4714
|
}
|
|
4677
4715
|
}
|
|
4678
4716
|
}
|
|
@@ -4691,13 +4729,15 @@ function formalParamsFromNodes(params) {
|
|
|
4691
4729
|
const top2 = [];
|
|
4692
4730
|
const nested2 = [];
|
|
4693
4731
|
const propKey2 = {};
|
|
4694
|
-
|
|
4732
|
+
const nestedPaths2 = [];
|
|
4733
|
+
if (left) collectPatternNames(left, top2, nested2, 0, propKey2, [], nestedPaths2);
|
|
4695
4734
|
return {
|
|
4696
4735
|
kind: "pattern",
|
|
4697
4736
|
placeholder: `_p${index}`,
|
|
4698
4737
|
bound: top2,
|
|
4699
4738
|
propKey: propKey2,
|
|
4700
4739
|
nested: nested2,
|
|
4740
|
+
nestedPaths: nestedPaths2,
|
|
4701
4741
|
index
|
|
4702
4742
|
};
|
|
4703
4743
|
}
|
|
@@ -4709,13 +4749,15 @@ function formalParamsFromNodes(params) {
|
|
|
4709
4749
|
const top = [];
|
|
4710
4750
|
const nested = [];
|
|
4711
4751
|
const propKey = {};
|
|
4712
|
-
|
|
4752
|
+
const nestedPaths = [];
|
|
4753
|
+
if (p) collectPatternNames(p, top, nested, 0, propKey, [], nestedPaths);
|
|
4713
4754
|
return {
|
|
4714
4755
|
kind: "pattern",
|
|
4715
4756
|
placeholder: `_p${index}`,
|
|
4716
4757
|
bound: top,
|
|
4717
4758
|
propKey,
|
|
4718
4759
|
nested,
|
|
4760
|
+
nestedPaths,
|
|
4719
4761
|
index
|
|
4720
4762
|
};
|
|
4721
4763
|
});
|
|
@@ -4757,6 +4799,7 @@ function contractParamNameSet(formals) {
|
|
|
4757
4799
|
out.add(f.placeholder);
|
|
4758
4800
|
out.add("_");
|
|
4759
4801
|
for (const b of f.bound) out.add(b);
|
|
4802
|
+
for (const np of f.nestedPaths) out.add(np);
|
|
4760
4803
|
}
|
|
4761
4804
|
}
|
|
4762
4805
|
return out;
|
|
@@ -4774,10 +4817,16 @@ function locateContractParam(formals, contractName) {
|
|
|
4774
4817
|
return { index: f.index };
|
|
4775
4818
|
}
|
|
4776
4819
|
if (f.bound.includes(contractName)) {
|
|
4777
|
-
|
|
4820
|
+
const field = f.propKey?.[contractName] ?? contractName;
|
|
4821
|
+
return { index: f.index, field, fieldPath: [field] };
|
|
4778
4822
|
}
|
|
4779
4823
|
}
|
|
4780
4824
|
}
|
|
4825
|
+
for (const f of formals) {
|
|
4826
|
+
if (f.kind === "pattern" && f.nestedPaths.includes(contractName)) {
|
|
4827
|
+
return { index: f.index, field: contractName, fieldPath: contractName.split(".") };
|
|
4828
|
+
}
|
|
4829
|
+
}
|
|
4781
4830
|
return void 0;
|
|
4782
4831
|
}
|
|
4783
4832
|
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
fnConstraintToEntryReqs,
|
|
16
16
|
foldRequireSpecArg,
|
|
17
17
|
formalParamDisplayNames,
|
|
18
|
+
formalParamSignatureNames,
|
|
18
19
|
formalParamsFromNodes,
|
|
19
20
|
formatAbs,
|
|
20
21
|
formatShape,
|
|
@@ -46,7 +47,7 @@ import {
|
|
|
46
47
|
withEvalBudgetOverride,
|
|
47
48
|
withExecPhi,
|
|
48
49
|
withFnBudgetOverride
|
|
49
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-PGTNSUTE.js";
|
|
50
51
|
|
|
51
52
|
// src/algebra/directive-scan.ts
|
|
52
53
|
function cleanDirectiveLine(raw, kind) {
|
|
@@ -3504,10 +3505,33 @@ function generalizeFromAstUncached(fnName, source, opts = {}) {
|
|
|
3504
3505
|
patternFields.set(hit.index, bag);
|
|
3505
3506
|
}
|
|
3506
3507
|
const fieldAbs = constraintToEntryAbs(e.constraint, e.param);
|
|
3507
|
-
|
|
3508
|
+
const leaf = {
|
|
3508
3509
|
abs: fieldAbs,
|
|
3509
3510
|
...e.constraint.isOptional ? { optional: true } : {}
|
|
3510
3511
|
};
|
|
3512
|
+
const segs = hit.fieldPath ?? [hit.field];
|
|
3513
|
+
if (segs.length <= 1) {
|
|
3514
|
+
bag[hit.field] = leaf;
|
|
3515
|
+
continue;
|
|
3516
|
+
}
|
|
3517
|
+
let level = bag;
|
|
3518
|
+
let skip = false;
|
|
3519
|
+
for (let i = 0; i < segs.length - 1; i++) {
|
|
3520
|
+
const node = level[segs[i]];
|
|
3521
|
+
if (node === void 0) {
|
|
3522
|
+
const sub = { slots: {} };
|
|
3523
|
+
level[segs[i]] = sub;
|
|
3524
|
+
level = sub.slots;
|
|
3525
|
+
} else if ("slots" in node) {
|
|
3526
|
+
level = node.slots;
|
|
3527
|
+
} else {
|
|
3528
|
+
skip = true;
|
|
3529
|
+
break;
|
|
3530
|
+
}
|
|
3531
|
+
}
|
|
3532
|
+
if (!skip) {
|
|
3533
|
+
level[segs[segs.length - 1]] = leaf;
|
|
3534
|
+
}
|
|
3511
3535
|
} else if (hit) {
|
|
3512
3536
|
const entryAbs = constraintToEntryAbs(e.constraint, e.param);
|
|
3513
3537
|
typeParams[hit.index] = {
|
|
@@ -3520,20 +3544,34 @@ function generalizeFromAstUncached(fnName, source, opts = {}) {
|
|
|
3520
3544
|
});
|
|
3521
3545
|
}
|
|
3522
3546
|
}
|
|
3523
|
-
|
|
3547
|
+
const sigNames = formalParamSignatureNames(formals);
|
|
3548
|
+
const buildPatternObjAbs = (slotsBag, sigName, walked) => {
|
|
3524
3549
|
const slots = {};
|
|
3525
|
-
for (const [key,
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3550
|
+
for (const [key, node] of Object.entries(slotsBag)) {
|
|
3551
|
+
if ("abs" in node) {
|
|
3552
|
+
slots[key] = {
|
|
3553
|
+
value: node.abs,
|
|
3554
|
+
...node.optional ? { optional: true } : {}
|
|
3555
|
+
};
|
|
3556
|
+
} else {
|
|
3557
|
+
slots[key] = {
|
|
3558
|
+
value: buildPatternObjAbs(node.slots, sigName, [...walked, key])
|
|
3559
|
+
};
|
|
3560
|
+
}
|
|
3530
3561
|
}
|
|
3531
|
-
|
|
3562
|
+
return abs(
|
|
3532
3563
|
{ k: "obj", slots },
|
|
3533
|
-
v(
|
|
3564
|
+
v(walked.length === 0 ? sigName : `${sigName}.${walked.join(".")}`),
|
|
3534
3565
|
void 0,
|
|
3535
3566
|
"path"
|
|
3536
3567
|
);
|
|
3568
|
+
};
|
|
3569
|
+
for (const [pIdx, bag] of patternFields) {
|
|
3570
|
+
const objAbs = buildPatternObjAbs(
|
|
3571
|
+
bag,
|
|
3572
|
+
sigNames[pIdx] ?? params[pIdx] ?? `_p${pIdx}`,
|
|
3573
|
+
[]
|
|
3574
|
+
);
|
|
3537
3575
|
typeParams[pIdx] = {
|
|
3538
3576
|
id: typeParams[pIdx].id,
|
|
3539
3577
|
value: objAbs
|
|
@@ -3677,6 +3715,7 @@ function generalizeFromAstUncached(fnName, source, opts = {}) {
|
|
|
3677
3715
|
}));
|
|
3678
3716
|
}
|
|
3679
3717
|
}
|
|
3718
|
+
const renderNames = formals.length > 0 ? formalParamSignatureNames(formals) : params;
|
|
3680
3719
|
return {
|
|
3681
3720
|
name: fnName,
|
|
3682
3721
|
params,
|
|
@@ -3685,6 +3724,7 @@ function generalizeFromAstUncached(fnName, source, opts = {}) {
|
|
|
3685
3724
|
instantiate: (args, phi) => run(args, phi ?? pTrue),
|
|
3686
3725
|
display: formatPoly(
|
|
3687
3726
|
fnName,
|
|
3727
|
+
renderNames,
|
|
3688
3728
|
params,
|
|
3689
3729
|
typeParams,
|
|
3690
3730
|
symbolic,
|
|
@@ -3699,12 +3739,13 @@ function generalizeFromAstUncached(fnName, source, opts = {}) {
|
|
|
3699
3739
|
...hofSites ? { hofSites } : {}
|
|
3700
3740
|
};
|
|
3701
3741
|
}
|
|
3702
|
-
function formatPoly(name, params, typeParams, symbolic, entryReqs, entryShapes, fnRels) {
|
|
3742
|
+
function formatPoly(name, renderNames, params, typeParams, symbolic, entryReqs, entryShapes, fnRels) {
|
|
3703
3743
|
const reqByParam = new Map((entryReqs ?? []).map((r) => [r.param, r.pred]));
|
|
3704
|
-
const ps =
|
|
3744
|
+
const ps = renderNames.map((p, i) => {
|
|
3745
|
+
const key = params[i] ?? p;
|
|
3705
3746
|
const id = typeParams[i]?.id ?? "unknown";
|
|
3706
|
-
const pred = reqByParam.get(
|
|
3707
|
-
const promoted = entryShapes?.get(
|
|
3747
|
+
const pred = reqByParam.get(key);
|
|
3748
|
+
const promoted = entryShapes?.get(key)?.abs ?? fnRels?.get(key)?.abs;
|
|
3708
3749
|
if (promoted) {
|
|
3709
3750
|
const slot = formatShapeSlot(promoted);
|
|
3710
3751
|
if (pred && pred.op !== "true") {
|
|
@@ -4480,13 +4521,17 @@ function scanLiteralCalls(source, knownFns, phi, opts) {
|
|
|
4480
4521
|
eiCache.set(key, r);
|
|
4481
4522
|
return r;
|
|
4482
4523
|
};
|
|
4483
|
-
const
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4524
|
+
const projectArgPath = (arg, segments) => {
|
|
4525
|
+
let cur = arg;
|
|
4526
|
+
for (const seg of segments) {
|
|
4527
|
+
if (!cur) return void 0;
|
|
4528
|
+
if (cur.shape.k === "brand") {
|
|
4529
|
+
cur = cur.shape.shape;
|
|
4530
|
+
}
|
|
4531
|
+
if (cur.shape.k !== "obj") return void 0;
|
|
4532
|
+
cur = getSlot(cur.shape.slots, seg)?.value;
|
|
4487
4533
|
}
|
|
4488
|
-
|
|
4489
|
-
return getSlot(arg.shape.slots, field)?.value;
|
|
4534
|
+
return cur;
|
|
4490
4535
|
};
|
|
4491
4536
|
const interfaceToIndexed = (ei, paramNames, formals) => {
|
|
4492
4537
|
const conflict = new Set(ei.conflict?.params ?? []);
|
|
@@ -4508,7 +4553,7 @@ function scanLiteralCalls(source, knownFns, phi, opts) {
|
|
|
4508
4553
|
entries.push([
|
|
4509
4554
|
hit.index,
|
|
4510
4555
|
{ param, pred: instantiateConstraint(constraint, param), constraint },
|
|
4511
|
-
hit.field
|
|
4556
|
+
hit.fieldPath ?? (hit.field !== void 0 ? [hit.field] : void 0)
|
|
4512
4557
|
]);
|
|
4513
4558
|
}
|
|
4514
4559
|
}
|
|
@@ -4544,17 +4589,18 @@ function scanLiteralCalls(source, knownFns, phi, opts) {
|
|
|
4544
4589
|
return lv <= n;
|
|
4545
4590
|
};
|
|
4546
4591
|
const checkReqs = (displayName, reqs, paramNames, absArgs, argIndexOf, loc) => {
|
|
4547
|
-
for (const [idx, pred,
|
|
4592
|
+
for (const [idx, pred, fieldPath, contractParam] of reqs) {
|
|
4548
4593
|
const argIdx = argIndexOf(idx);
|
|
4549
4594
|
if (argIdx === void 0) continue;
|
|
4550
4595
|
let arg = absArgs[argIdx];
|
|
4551
4596
|
if (!arg) continue;
|
|
4552
4597
|
const paramName = contractParam || paramNames[idx] || `arg${idx}`;
|
|
4553
|
-
if (
|
|
4554
|
-
const projected =
|
|
4598
|
+
if (fieldPath) {
|
|
4599
|
+
const projected = projectArgPath(arg, fieldPath);
|
|
4555
4600
|
if (!projected) {
|
|
4556
4601
|
const k = arg.shape.k;
|
|
4557
4602
|
if (k !== "unknown" && k !== "any") {
|
|
4603
|
+
const field = fieldPath.join(".");
|
|
4558
4604
|
out.push({
|
|
4559
4605
|
severity: "error",
|
|
4560
4606
|
code: "nudo:constraint-violated",
|
|
@@ -4895,7 +4941,7 @@ function scanLiteralCalls(source, knownFns, phi, opts) {
|
|
|
4895
4941
|
}
|
|
4896
4942
|
};
|
|
4897
4943
|
const checkShapeReqs = (displayName, reqs, paramNames, absArgs, argIndexOf, loc) => {
|
|
4898
|
-
for (const [idx, entry,
|
|
4944
|
+
for (const [idx, entry, fieldPath] of reqs) {
|
|
4899
4945
|
const c = entry.constraint;
|
|
4900
4946
|
if (!c.fields && !c.element && !isIntFlag(c) && !c.prim) continue;
|
|
4901
4947
|
const argIdx = argIndexOf(idx);
|
|
@@ -4903,11 +4949,12 @@ function scanLiteralCalls(source, knownFns, phi, opts) {
|
|
|
4903
4949
|
let arg = absArgs[argIdx];
|
|
4904
4950
|
if (!arg) continue;
|
|
4905
4951
|
const paramName = entry.param || paramNames[idx] || `arg${idx}`;
|
|
4906
|
-
if (
|
|
4907
|
-
const projected =
|
|
4952
|
+
if (fieldPath) {
|
|
4953
|
+
const projected = projectArgPath(arg, fieldPath);
|
|
4908
4954
|
if (!projected) {
|
|
4909
4955
|
const k = arg.shape.k;
|
|
4910
4956
|
if (k !== "unknown" && k !== "any") {
|
|
4957
|
+
const field = fieldPath.join(".");
|
|
4911
4958
|
out.push({
|
|
4912
4959
|
severity: "error",
|
|
4913
4960
|
code: "nudo:constraint-violated",
|
package/dist/exec.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -847,6 +847,11 @@ type FormalParam = {
|
|
|
847
847
|
propKey: Record<string, string>;
|
|
848
848
|
/** 仅嵌套内出现、顶层不可单独表达的名(降级用) */
|
|
849
849
|
nested: string[];
|
|
850
|
+
/**
|
|
851
|
+
* #137:嵌套解构点路径契约面('card.grade',源属性键点连接)。
|
|
852
|
+
* 中间键(card)同时在 bound 里平铺可绑(整对象 shape 契约)。
|
|
853
|
+
*/
|
|
854
|
+
nestedPaths: string[];
|
|
850
855
|
index: number;
|
|
851
856
|
};
|
|
852
857
|
type AstParam = {
|
|
@@ -877,13 +882,17 @@ declare function contractParamNameSet(formals: FormalParam[]): Set<string>;
|
|
|
877
882
|
/**
|
|
878
883
|
* 契约参数名 → 形参定位。
|
|
879
884
|
* - 命中 id/default/rest → 该 index(执法按整参)
|
|
880
|
-
* - 命中 pattern 顶层 bound 名 → 该 pattern index + field
|
|
885
|
+
* - 命中 pattern 顶层 bound 名 → 该 pattern index + field(fieldPath 单段)
|
|
881
886
|
* - 命中 placeholder / `_` → pattern index(整对象)
|
|
887
|
+
* - #137:命中嵌套点路径('card.grade' ∈ nestedPaths)→ index + fieldPath
|
|
888
|
+
* 多段(field 为展示用点连接串)。平铺精确匹配必须先于任何点路径解析:
|
|
889
|
+
* 源键 'a.b' 与路径 'a.b' 不可歧义——平铺胜。
|
|
882
890
|
* - 未命中 → undefined(C4.5 param-mismatch)
|
|
883
891
|
*/
|
|
884
892
|
declare function locateContractParam(formals: FormalParam[], contractName: string): {
|
|
885
893
|
index: number;
|
|
886
894
|
field?: string;
|
|
895
|
+
fieldPath?: string[];
|
|
887
896
|
rest?: boolean;
|
|
888
897
|
} | undefined;
|
|
889
898
|
|
package/dist/index.js
CHANGED
|
@@ -64,7 +64,7 @@ import {
|
|
|
64
64
|
takeInterfaceDiagsSince,
|
|
65
65
|
takeRefineDiags,
|
|
66
66
|
takeRefineDiagsSince
|
|
67
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-S7HJL5GW.js";
|
|
68
68
|
import {
|
|
69
69
|
$add,
|
|
70
70
|
$arguments,
|
|
@@ -520,7 +520,7 @@ import {
|
|
|
520
520
|
v,
|
|
521
521
|
withExecPhi,
|
|
522
522
|
withVar
|
|
523
|
-
} from "./chunk-
|
|
523
|
+
} from "./chunk-PGTNSUTE.js";
|
|
524
524
|
|
|
525
525
|
// src/environment.ts
|
|
526
526
|
function createEnvironment(parent, bindings = /* @__PURE__ */ new Map()) {
|
|
@@ -1920,13 +1920,17 @@ function structuralAssignIssues(records) {
|
|
|
1920
1920
|
}
|
|
1921
1921
|
|
|
1922
1922
|
// src/algebra/check-case-scan.ts
|
|
1923
|
-
function projectCaseArgField(arg,
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1923
|
+
function projectCaseArgField(arg, fieldPath) {
|
|
1924
|
+
let cur = arg;
|
|
1925
|
+
for (const seg of fieldPath) {
|
|
1926
|
+
if (!cur) return void 0;
|
|
1927
|
+
if (cur.shape.k === "brand") {
|
|
1928
|
+
cur = cur.shape.shape;
|
|
1929
|
+
}
|
|
1930
|
+
if (cur.shape.k !== "obj") return void 0;
|
|
1931
|
+
cur = getSlot(cur.shape.slots, seg)?.value;
|
|
1927
1932
|
}
|
|
1928
|
-
|
|
1929
|
-
return getSlot(arg.shape.slots, field)?.value;
|
|
1933
|
+
return cur;
|
|
1930
1934
|
}
|
|
1931
1935
|
function scanCaseInconsistency(source, knownFns, opts) {
|
|
1932
1936
|
const out = [];
|
|
@@ -2007,12 +2011,12 @@ function scanCaseInconsistency(source, knownFns, opts) {
|
|
|
2007
2011
|
for (const p of eff.params) {
|
|
2008
2012
|
if (conflictParams.has(p.param)) continue;
|
|
2009
2013
|
let idx = paramNames.indexOf(p.param);
|
|
2010
|
-
let
|
|
2014
|
+
let fieldPath;
|
|
2011
2015
|
if (idx < 0 && formals.length > 0) {
|
|
2012
2016
|
const hit = locateContractParam(formals, p.param);
|
|
2013
2017
|
if (hit) {
|
|
2014
2018
|
idx = hit.index;
|
|
2015
|
-
|
|
2019
|
+
fieldPath = hit.fieldPath ?? (hit.field !== void 0 ? [hit.field] : void 0);
|
|
2016
2020
|
}
|
|
2017
2021
|
}
|
|
2018
2022
|
if (idx < 0) continue;
|
|
@@ -2023,7 +2027,7 @@ function scanCaseInconsistency(source, knownFns, opts) {
|
|
|
2023
2027
|
pred: instantiateConstraint(p.constraint, p.param),
|
|
2024
2028
|
constraint: p.constraint
|
|
2025
2029
|
},
|
|
2026
|
-
|
|
2030
|
+
fieldPath
|
|
2027
2031
|
]);
|
|
2028
2032
|
}
|
|
2029
2033
|
if (reqs.length === 0) return;
|
|
@@ -2031,16 +2035,17 @@ function scanCaseInconsistency(source, knownFns, opts) {
|
|
|
2031
2035
|
for (const req of reqs) {
|
|
2032
2036
|
const idx = req[0];
|
|
2033
2037
|
const entry = req[1];
|
|
2034
|
-
const
|
|
2038
|
+
const fieldPath = req[2];
|
|
2035
2039
|
if (entry.constraint.fields) continue;
|
|
2036
2040
|
let arg = absArgs[idx];
|
|
2037
2041
|
if (!arg) continue;
|
|
2038
|
-
if (
|
|
2039
|
-
const projected = projectCaseArgField(arg,
|
|
2042
|
+
if (fieldPath) {
|
|
2043
|
+
const projected = projectCaseArgField(arg, fieldPath);
|
|
2040
2044
|
if (!projected) {
|
|
2041
2045
|
const k = arg.shape.k;
|
|
2042
2046
|
if (k !== "unknown" && k !== "any") {
|
|
2043
2047
|
const paramName = entry.param || paramNames[idx] || `arg${idx}`;
|
|
2048
|
+
const field = fieldPath.join(".");
|
|
2044
2049
|
out.push({
|
|
2045
2050
|
severity: "error",
|
|
2046
2051
|
code: "nudo:case-inconsistency",
|
package/dist/internal.js
CHANGED
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
stableAnalyzeKeySource,
|
|
22
22
|
stablePathKey,
|
|
23
23
|
stablePathKeyGraph
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-S7HJL5GW.js";
|
|
25
25
|
import {
|
|
26
26
|
$tryDigestSoft,
|
|
27
27
|
$tryMarkSoft,
|
|
@@ -169,7 +169,7 @@ import {
|
|
|
169
169
|
withEvalBudgetOverride,
|
|
170
170
|
withFnBudgetOverride,
|
|
171
171
|
wrapPromise
|
|
172
|
-
} from "./chunk-
|
|
172
|
+
} from "./chunk-PGTNSUTE.js";
|
|
173
173
|
|
|
174
174
|
// src/algebra/inlay.ts
|
|
175
175
|
function listFunctions(source) {
|