@nudojs/core 1.7.0 → 1.7.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.
|
@@ -3128,6 +3128,29 @@ function filterDeclaredThrows(effects, declared) {
|
|
|
3128
3128
|
}
|
|
3129
3129
|
|
|
3130
3130
|
// src/algebra/arithmetic.ts
|
|
3131
|
+
function distributeSumBinOp(op, a, b, phi2, eval2) {
|
|
3132
|
+
if (a.shape.k !== "sum" && b.shape.k !== "sum") return void 0;
|
|
3133
|
+
const parts = [];
|
|
3134
|
+
const as = a.shape.k === "sum" ? a.shape.members : [a];
|
|
3135
|
+
const bs = b.shape.k === "sum" ? b.shape.members : [b];
|
|
3136
|
+
for (const x of as) {
|
|
3137
|
+
for (const y of bs) {
|
|
3138
|
+
const r = eval2(x, y, phi2);
|
|
3139
|
+
if (r.shape.k === "never") continue;
|
|
3140
|
+
if (r.shape.k === "sum") parts.push(...r.shape.members);
|
|
3141
|
+
else parts.push(r);
|
|
3142
|
+
}
|
|
3143
|
+
}
|
|
3144
|
+
const uniq = dedupAbsMembers(parts);
|
|
3145
|
+
const term = a.term && b.term ? simplifyTerm(app(op, [a.term, b.term])) : void 0;
|
|
3146
|
+
if (uniq.length === 0) {
|
|
3147
|
+
return abs({ k: "unknown" }, term, void 0, "partial");
|
|
3148
|
+
}
|
|
3149
|
+
if (uniq.length === 1) {
|
|
3150
|
+
return abs(uniq[0].shape, term, uniq[0].pred, confJoin(a.conf, b.conf));
|
|
3151
|
+
}
|
|
3152
|
+
return abs({ k: "sum", members: uniq }, term, void 0, "partial");
|
|
3153
|
+
}
|
|
3131
3154
|
function add(a, b, phi2 = pTrue) {
|
|
3132
3155
|
if (isSymbolAbs(a) || isSymbolAbs(b)) {
|
|
3133
3156
|
throw new NudoThrow(errorTypeAbs("TypeError"));
|
|
@@ -3185,28 +3208,8 @@ function add(a, b, phi2 = pTrue) {
|
|
|
3185
3208
|
"partial"
|
|
3186
3209
|
);
|
|
3187
3210
|
}
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
const as = a.shape.k === "sum" ? a.shape.members : [a];
|
|
3191
|
-
const bs = b.shape.k === "sum" ? b.shape.members : [b];
|
|
3192
|
-
for (const x of as) {
|
|
3193
|
-
for (const y of bs) {
|
|
3194
|
-
const r = add(x, y, phi2);
|
|
3195
|
-
if (r.shape.k === "never") continue;
|
|
3196
|
-
if (r.shape.k === "sum") parts.push(...r.shape.members);
|
|
3197
|
-
else parts.push(r);
|
|
3198
|
-
}
|
|
3199
|
-
}
|
|
3200
|
-
const uniq = dedupAbsMembers(parts);
|
|
3201
|
-
const term = a.term && b.term ? simplifyTerm(app("+", [a.term, b.term])) : void 0;
|
|
3202
|
-
if (uniq.length === 0) {
|
|
3203
|
-
return abs({ k: "unknown" }, term, void 0, "partial");
|
|
3204
|
-
}
|
|
3205
|
-
if (uniq.length === 1) {
|
|
3206
|
-
return abs(uniq[0].shape, term, uniq[0].pred, confJoin(a.conf, b.conf));
|
|
3207
|
-
}
|
|
3208
|
-
return abs({ k: "sum", members: uniq }, term, void 0, "partial");
|
|
3209
|
-
}
|
|
3211
|
+
const distributed = distributeSumBinOp("+", a, b, phi2, add);
|
|
3212
|
+
if (distributed) return distributed;
|
|
3210
3213
|
if (isNumPrim(a) || isNumPrim(b) || isBigPrim(a) || isBigPrim(b) || a.shape.k === "unknown" || b.shape.k === "unknown" || a.shape.k === "obj" || b.shape.k === "obj" || a.shape.k === "fn" || b.shape.k === "fn" || a.shape.k === "brand" || b.shape.k === "brand") {
|
|
3211
3214
|
return abs({ k: "sum", members: [num(), str()] }, void 0, void 0, "partial");
|
|
3212
3215
|
}
|
|
@@ -3323,6 +3326,35 @@ function addPred(a, b, sumTerm, phi2) {
|
|
|
3323
3326
|
return and(...facts);
|
|
3324
3327
|
}
|
|
3325
3328
|
function numericBounds(a, phi2 = pTrue) {
|
|
3329
|
+
if (a.shape.k === "sum") {
|
|
3330
|
+
const members = a.shape.members;
|
|
3331
|
+
let lo;
|
|
3332
|
+
let hi;
|
|
3333
|
+
let loOpen = false;
|
|
3334
|
+
let hiOpen = false;
|
|
3335
|
+
for (const m of members) {
|
|
3336
|
+
const mb = numericBounds(m, phi2);
|
|
3337
|
+
if (!mb) return void 0;
|
|
3338
|
+
if (mb.lo === void 0) {
|
|
3339
|
+
loOpen = true;
|
|
3340
|
+
} else if (!loOpen) {
|
|
3341
|
+
if (lo === void 0 || mb.lo.value < lo.value || mb.lo.value === lo.value && !mb.lo.strict && lo.strict) {
|
|
3342
|
+
lo = mb.lo;
|
|
3343
|
+
}
|
|
3344
|
+
}
|
|
3345
|
+
if (mb.hi === void 0) {
|
|
3346
|
+
hiOpen = true;
|
|
3347
|
+
} else if (!hiOpen) {
|
|
3348
|
+
if (hi === void 0 || mb.hi.value > hi.value || mb.hi.value === hi.value && !mb.hi.strict && hi.strict) {
|
|
3349
|
+
hi = mb.hi;
|
|
3350
|
+
}
|
|
3351
|
+
}
|
|
3352
|
+
}
|
|
3353
|
+
if (loOpen) lo = void 0;
|
|
3354
|
+
if (hiOpen) hi = void 0;
|
|
3355
|
+
if (lo === void 0 && hi === void 0) return void 0;
|
|
3356
|
+
return { lo, hi };
|
|
3357
|
+
}
|
|
3326
3358
|
if (!isNumPrim(a)) return void 0;
|
|
3327
3359
|
const result = {};
|
|
3328
3360
|
if (a.pred && a.term) {
|
|
@@ -3429,6 +3461,8 @@ function sub(a, b, phi2 = pTrue) {
|
|
|
3429
3461
|
if (isAnyLike(a) || isAnyLike(b)) {
|
|
3430
3462
|
return toNumberResult(a, b, "-");
|
|
3431
3463
|
}
|
|
3464
|
+
const distributed = distributeSumBinOp("-", a, b, phi2, sub);
|
|
3465
|
+
if (distributed) return distributed;
|
|
3432
3466
|
return abs({ k: "unknown" }, void 0, void 0, "partial");
|
|
3433
3467
|
}
|
|
3434
3468
|
function mul(a, b, phi2 = pTrue) {
|
|
@@ -3501,6 +3535,8 @@ function mul(a, b, phi2 = pTrue) {
|
|
|
3501
3535
|
if (isAnyLike(a) || isAnyLike(b)) {
|
|
3502
3536
|
return toNumberResult(a, b, "*");
|
|
3503
3537
|
}
|
|
3538
|
+
const distributed = distributeSumBinOp("*", a, b, phi2, mul);
|
|
3539
|
+
if (distributed) return distributed;
|
|
3504
3540
|
return abs({ k: "unknown" }, void 0, void 0, "partial");
|
|
3505
3541
|
}
|
|
3506
3542
|
function div(a, b, phi2 = pTrue) {
|
|
@@ -3561,6 +3597,8 @@ function div(a, b, phi2 = pTrue) {
|
|
|
3561
3597
|
if (isAnyLike(a) || isAnyLike(b)) {
|
|
3562
3598
|
return toNumberResult(a, b, "/");
|
|
3563
3599
|
}
|
|
3600
|
+
const distributed = distributeSumBinOp("/", a, b, phi2, div);
|
|
3601
|
+
if (distributed) return distributed;
|
|
3564
3602
|
return abs({ k: "unknown" }, void 0, void 0, "partial");
|
|
3565
3603
|
}
|
|
3566
3604
|
function mod(a, b, phi2 = pTrue) {
|
|
@@ -3611,6 +3649,8 @@ function mod(a, b, phi2 = pTrue) {
|
|
|
3611
3649
|
if (isAnyLike(a) || isAnyLike(b)) {
|
|
3612
3650
|
return toNumberResult(a, b, "%");
|
|
3613
3651
|
}
|
|
3652
|
+
const distributed = distributeSumBinOp("%", a, b, phi2, mod);
|
|
3653
|
+
if (distributed) return distributed;
|
|
3614
3654
|
return abs({ k: "unknown" }, void 0, void 0, "partial");
|
|
3615
3655
|
}
|
|
3616
3656
|
function cmp(op, a, b, phi2 = pTrue) {
|
|
@@ -4156,6 +4196,11 @@ function isNonNaN(a, phi2) {
|
|
|
4156
4196
|
if (a.term?.op === "lit") {
|
|
4157
4197
|
return typeof a.term.value === "number" && !Number.isNaN(a.term.value);
|
|
4158
4198
|
}
|
|
4199
|
+
if (a.shape.k === "sum") {
|
|
4200
|
+
return a.shape.members.every(
|
|
4201
|
+
(m) => isNonNaN(m, phi2)
|
|
4202
|
+
);
|
|
4203
|
+
}
|
|
4159
4204
|
const hasNonNaNFact = (p) => {
|
|
4160
4205
|
if (!p) return false;
|
|
4161
4206
|
if (p.op === "and") return p.args.some(hasNonNaNFact);
|
|
@@ -4277,7 +4322,9 @@ function roundingAbs(name, arg) {
|
|
|
4277
4322
|
const impl = name === "round" ? Math.round : name === "floor" ? Math.floor : name === "ceil" ? Math.ceil : Math.trunc;
|
|
4278
4323
|
const b = numericBounds(arg, phi2);
|
|
4279
4324
|
const mayNaN = !isNonNaN(arg, phi2);
|
|
4280
|
-
const term =
|
|
4325
|
+
const term = simplifyTerm(
|
|
4326
|
+
app(`Math.${name}`, [arg.term ?? app("arg0", [])])
|
|
4327
|
+
);
|
|
4281
4328
|
let out = {};
|
|
4282
4329
|
if (b) {
|
|
4283
4330
|
if (b.lo !== void 0) {
|
|
@@ -4289,7 +4336,7 @@ function roundingAbs(name, arg) {
|
|
|
4289
4336
|
out.hi = Number.isNaN(v2) ? void 0 : { value: v2, strict: false };
|
|
4290
4337
|
}
|
|
4291
4338
|
}
|
|
4292
|
-
const pred =
|
|
4339
|
+
const pred = boundsToPred(term, out);
|
|
4293
4340
|
const bounded = abs({ k: "prim", type: "number" }, term, pred, "path");
|
|
4294
4341
|
if (!mayNaN) return bounded;
|
|
4295
4342
|
return makeSum(numLit(NaN), bounded);
|
package/dist/exec.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -91,7 +91,7 @@ import {
|
|
|
91
91
|
takeRefineDiagsSince,
|
|
92
92
|
throwConstraintToKinds,
|
|
93
93
|
union
|
|
94
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-GC7VNUCB.js";
|
|
95
95
|
import {
|
|
96
96
|
$add,
|
|
97
97
|
$arguments,
|
|
@@ -509,7 +509,7 @@ import {
|
|
|
509
509
|
v,
|
|
510
510
|
withExecPhi,
|
|
511
511
|
withVar
|
|
512
|
-
} from "./chunk-
|
|
512
|
+
} from "./chunk-BM3UPEA7.js";
|
|
513
513
|
|
|
514
514
|
// src/environment.ts
|
|
515
515
|
function createEnvironment(parent, bindings = /* @__PURE__ */ new Map()) {
|
package/dist/internal.js
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
stableAnalyzeKeySource,
|
|
20
20
|
stablePathKey,
|
|
21
21
|
stablePathKeyGraph
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-GC7VNUCB.js";
|
|
23
23
|
import {
|
|
24
24
|
$tryDigestSoft,
|
|
25
25
|
$tryMarkSoft,
|
|
@@ -160,7 +160,7 @@ import {
|
|
|
160
160
|
withEvalBudgetOverride,
|
|
161
161
|
withFnBudgetOverride,
|
|
162
162
|
wrapPromise
|
|
163
|
-
} from "./chunk-
|
|
163
|
+
} from "./chunk-BM3UPEA7.js";
|
|
164
164
|
|
|
165
165
|
// src/algebra/inlay.ts
|
|
166
166
|
function listFunctions(source) {
|