@nudojs/core 1.15.2 → 1.17.0
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-NXZSRLCT.js → chunk-4MRLOJMI.js} +4141 -1119
- package/dist/{chunk-WKIRPUHZ.js → chunk-ARIQO5XX.js} +33102 -23074
- package/dist/exec.d.ts +666 -129
- package/dist/exec.js +16 -16
- package/dist/index.d.ts +428 -96
- package/dist/index.js +1244 -517
- package/dist/internal.d.ts +82 -43
- package/dist/internal.js +144 -141
- package/dist/{projection-budget-07VnMktV.d.ts → projection-budget-BkFV9pcs.d.ts} +178 -42
- package/dist/{run-DfloWX6i.d.ts → run-tV2J7PNI.d.ts} +114 -41
- package/package.json +1 -1
- /package/dist/{chunk-US532PZA.js → chunk-II73GZOY.js} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { d as AstEnv, A as Abs,
|
|
2
|
-
export {
|
|
1
|
+
import { d as AstEnv, A as Abs, C as Confidence, a as Pred, b as Phi, S as Shape, Q as RelSource, U as HofSite, c as AbsModuleExports, R as RunTranspiledOptions, L as LiteralValue } from './run-tV2J7PNI.js';
|
|
2
|
+
export { V as $assignRecord, W as $call, X as $callNamed, Y as $recordBinding, Z as AbsApplyNoThrow, _ as AbsApplyNoThrowFn, a0 as AbsApplyResult, a1 as AbsApplyReturn, a2 as AbsFnImpl, a3 as AbsSigImpl, a4 as EvalAbsAssignRecord, a5 as EvalCallRecord, a6 as EvalFallback, a7 as EvalPosRecord, a8 as ImplicationOracle, a9 as LitValueResult, aa as MAX_EVAL_CALL_DEPTH, ab as MAX_EVAL_TOTAL_CALLS, P as PrimName, ac as TYPEOF_NAMES, T as Term, ad as TranspiledCallResult, ae as TypeofName, af as abs, ag as absFunction, ah as absOnly, ai as absToString, aj as and, ak as anyAbs, al as anyVar, am as app, an as assumeFinite, ao as attachFnImpl, ap as bigintLit, aq as bindImports, ar as bindingsOf, as as bool, at as boolLit, au as callTranspiledExport, av as callTranspiledExportApply, aw as callTranspiledExportFull, ax as collectAbsExports, ay as confJoin, az as emptyPhi, aA as eq, aB as evalExprAbs, aC as ge, aD as geNum, aE as getEvalCallCollector, aF as getFnImpl, aG as getImplicationOracle, aH as gt, aI as gtNum, aJ as hostFnCtorFacet, aK as implies, aL as isAbsApplyResult, aM as isAbsVal, aN as isBigPrim, aO as isCjsMainRun, aP as isExactLit, aQ as isNumPrim, aR as isStrPrim, aS as le, aT as leNum, aU as lit, aV as litValue, aW as lt, aX as ltNum, aY as makeAbsApplyResult, aZ as markPureFn, a_ as namespaceAbsOf, a$ as ne, b0 as negatePred, b1 as never, b2 as not, b3 as noteEvalCallRecord, b4 as noteEvalFallback, b5 as num, b6 as numLit, b7 as numVar, b8 as obj, b9 as or, ba as pFalse, bb as pTrue, bc as phiAnd, bd as predEquals, be as predToString, bf as predVars, bg as primToTypeof, bh as ptypeof, bi as pureFnNameOf, bj as relationFingerprint, bk as relationFn, bl as resetEvalCallBudget, bm as runTranspiled, bn as runTranspiledOptionsMemoKey, bo as setEvalAssignCollector, bp as setEvalBindingSink, bq as setEvalCallCollector, br as setEvalFallbackCollector, bs as setImplicationOracle, bt as setPosCollector, bu as shapeOfTerm, bv as shapeOnlyFn, bw as shapeToString, bx as simplifyTerm, by as str, bz as strLit, bA as substPred, bB as termEquals, bC as termToString, bD as tryRunTranspiled, bE as unknown, bF as v } from './run-tV2J7PNI.js';
|
|
3
3
|
import { Node, File } from '@babel/types';
|
|
4
|
-
import { p as parseSource, L as LeakBudget, E as EffectiveInterfaceOpts, b as LoadDepsFingerprint, w as CheckReport, N as NudoConstraint, c as ProjectionBudget } from './projection-budget-
|
|
5
|
-
export { x as CONSTRAINT_BUILDERS, y as CONSTRAINT_BUILDER_NAMES, z as CONSTRAINT_EXPR_RE, A as CheckAction, C as CheckIssue, B as CheckJson, D as CheckJsonMulti, F as ConstraintBuilder, G as Diagnostic, H as EffectiveInterface, J as GitlabCodeQualityIssue, K as INTERFACE_SOURCE_ABBR, O as InterfaceDiag, I as InterfaceSource, Q as InterfaceTierInfo, a as InterfaceTierOpts, R as NamedImport, S as NudoField, T as NudoFnConstraint, U as NudoSidecarError, V as NudoSig, W as RefineDiag, X as RefineEntry, Y as RefineResolveOpts, Z as SELF, _ as actionsForIssue, $ as andC, a0 as any, a1 as array, a2 as boolean, a3 as checkArg, a4 as checkCall, a5 as constraintAdmitsNullish, a6 as constraintToEntryAbs, a7 as derefConstraint, a8 as drainPromiseMicros, a9 as effectiveInterface, aa as enterPromiseExecutorScope, ab as evalPromiseCtor, ac as evalPromiseMethod, ad as evalPromiseStatic, ae as execNudoModule, af as extractDeclaredThrows, ag as extractFnBudget, ah as extractNudoImports, ai as extractRefineReturnFromSource, aj as extractRefinesFromSource, ak as fn, al as fnConstraintToEntryReqs, am as formatCheckReport, an as formatConstraint, ao as formatDiagnostics, ap as formatEffectiveInterfaceDisplay, aq as formatGithubAnnotations, ar as formatGitlabCodeQuality, as as formatInterfaceTierLine, at as generatedExportNames, au as getParseSourceCacheSize, av as getTerm, aw as instantiateConstraint, ax as interfaceDiagCount, ay as interfaceSourceOf, az as interfaceTierOf, aA as isIntFlag, aB as isNodeModulesPath, aC as isNudoConstraint, aD as lazy, aE as leavePromiseExecutorScope, aF as lenTerm, aG as litC, aH as localNamedExports, aI as notePromiseExecutorFork, aJ as nullable, aK as number, aL as omit, aM as partial, aN as pick, aO as queuePromiseMicro, aP as refineDiagCount, aQ as refineToIndexedFull, aR as resetNudoModuleExecCache, aS as resetParseSourceCache, aT as resetSidecarLoadFailureCache, aU as serializeCheckJson, aV as serializeCheckJsonMulti, aW as setInterfaceDiagCollector, aX as setRefineDiagCollector, aY as shape, aZ as sidecarClosureFingerprint, a_ as sidecarPathOf, a$ as string, b0 as takeInterfaceDiags, b1 as takeInterfaceDiagsSince, b2 as takeRefineDiags, b3 as takeRefineDiagsSince, b4 as throwConstraintToKinds, b5 as union } from './projection-budget-
|
|
6
|
-
export { $add, $arguments, $arr, $arrMutContainer, $arrRest, $arrWithHoles, $async, $
|
|
4
|
+
import { p as parseSource, L as LeakBudget, E as EffectiveInterfaceOpts, b as LoadDepsFingerprint, w as CheckReport, N as NudoConstraint, c as ProjectionBudget } from './projection-budget-BkFV9pcs.js';
|
|
5
|
+
export { x as CONSTRAINT_BUILDERS, y as CONSTRAINT_BUILDER_NAMES, z as CONSTRAINT_EXPR_RE, A as CheckAction, C as CheckIssue, B as CheckJson, D as CheckJsonMulti, F as ConstraintBuilder, G as Diagnostic, H as EffectiveInterface, J as GitlabCodeQualityIssue, K as INTERFACE_SOURCE_ABBR, O as InterfaceDiag, I as InterfaceSource, Q as InterfaceTierInfo, a as InterfaceTierOpts, R as NamedImport, S as NudoField, T as NudoFnConstraint, U as NudoSidecarError, V as NudoSig, W as RefineDiag, X as RefineEntry, Y as RefineResolveOpts, Z as SELF, _ as actionsForIssue, $ as andC, a0 as any, a1 as array, a2 as boolean, a3 as checkArg, a4 as checkCall, a5 as constraintAdmitsNullish, a6 as constraintToEntryAbs, a7 as derefConstraint, a8 as drainPromiseMicros, a9 as effectiveInterface, aa as enterPromiseExecutorScope, ab as evalPromiseCtor, ac as evalPromiseMethod, ad as evalPromiseStatic, ae as execNudoModule, af as extractDeclaredThrows, ag as extractFnBudget, ah as extractNudoImports, ai as extractRefineReturnFromSource, aj as extractRefinesFromSource, ak as fn, al as fnConstraintToEntryReqs, am as formatCheckReport, an as formatConstraint, ao as formatDiagnostics, ap as formatEffectiveInterfaceDisplay, aq as formatGithubAnnotations, ar as formatGitlabCodeQuality, as as formatInterfaceTierLine, at as generatedExportNames, au as getParseSourceCacheSize, av as getTerm, aw as instantiateConstraint, ax as interfaceDiagCount, ay as interfaceSourceOf, az as interfaceTierOf, aA as isIntFlag, aB as isNodeModulesPath, aC as isNudoConstraint, aD as lazy, aE as leavePromiseExecutorScope, aF as lenTerm, aG as litC, aH as localNamedExports, aI as notePromiseExecutorFork, aJ as nullable, aK as number, aL as omit, aM as partial, aN as pick, aO as queuePromiseMicro, aP as refineDiagCount, aQ as refineToIndexedFull, aR as resetNudoModuleExecCache, aS as resetParseSourceCache, aT as resetSidecarLoadFailureCache, aU as serializeCheckJson, aV as serializeCheckJsonMulti, aW as setInterfaceDiagCollector, aX as setRefineDiagCollector, aY as shape, aZ as sidecarClosureFingerprint, a_ as sidecarPathOf, a$ as string, b0 as takeInterfaceDiags, b1 as takeInterfaceDiagsSince, b2 as takeRefineDiags, b3 as takeRefineDiagsSince, b4 as throwConstraintToKinds, b5 as union } from './projection-budget-BkFV9pcs.js';
|
|
6
|
+
export { $add, $arguments, $arr, $arrMutContainer, $arrRest, $arrWithHoles, $async, $await, $bitand, $bitnot, $bitor, $bitxor, $catchVal, $class, $classExpr, $collectionForEach, $concat, $copy, $del, $delRes, $div, $dynamicImport, $elems, $eq, $eqLoose, $fnVal, $for, $forInKeys, $forOf, $fork, $ge, $gen, $get, $gt, $idx, $idxSet, $importMeta, $in, $instanceof, $instanceofNonIdent, $invoke, $invokeSuper, $isBreakTo, $isForkExit, $join, $le, $len, $lit, $loopBreak, $loopContinue, $loopReturn, $lt, $mod, $mul, $ne, $neLoose, $neg, $new, $not, $nullishTest, $obj, $objAccessor, $objRest, $optionalGet, $optionalInvoke, $orDefault, $pow, $pushLoopExit, $rawThis, $reStateCall, $regex, $rethrowIfNudoReturn, $set, $setKey, $shl, $shr, $spread, $sub, $super, $switch, $throw, $toNumber, $toNumeric, $tryCurrentMark, $tryDetachSoftCatch, $tryDigestSoftCatch, $tryDiscardSoft, $tryMark, $tryOrphanSoft, $tryPopMark, $tryReleaseSoftCatch, $tryReleaseSoftOut, $tryTakeSince, $typeof, $unknown, $updateAdd, $updateSub, $ushr, $whileSeq, $yield, DEFAULT_MAX_LOOP_ITERS, EvalClassSpec, NudoLoopSignal, NudoReturn, NudoThrow, NudoUnsupportedError, RUNTIME_IMPORT_RE, TranspileOptions, asAbsVal, callAtFunctionBoundary, clearBClasses, clearStaleTermPred, currentExecPhi, fillTuple, foldRequireSpecArg, foldStaticStringExpr, getEvalClass, isArrMutator, isDefinitelyFalse, isDefinitelyTrue, isNudoBreak, isNudoContinue, isNudoReturn, isNudoThrow, litTruth, lookupObjAccessor, namespaceNameOf, pushLoopExit, pushThrowExit, registerEvalClass, runWithLoopExits, runtimeImportOf, takeLoopExits, takeThrowExits, transpile, transpileBodyNode, transpileExpression, transpileFile, transpileSource, withExecPhi } from './exec.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* AstEnv:抽象求值环境类型面(ast-eval 删除后保留)。
|
|
@@ -86,85 +86,70 @@ declare namespace spy {
|
|
|
86
86
|
*/
|
|
87
87
|
declare function mock(): MockHelper;
|
|
88
88
|
|
|
89
|
+
/**
|
|
90
|
+
* 剥除选项(**可选**能力;分析面不传 ⇒ 行为与旧版逐字一致)。
|
|
91
|
+
*
|
|
92
|
+
* - report:剥除**事实**回报(只写不改)。migrate strip 的 notes 据此判定
|
|
93
|
+
* 「提示与事实是否一致」——注释 / 字符串里的 "enum " / "namespace "
|
|
94
|
+
* 不是声明,裸正则会误报(Bug 596)。
|
|
95
|
+
* - resolveSpecifier:相对说明符改写(migrate strip 的**产物**面)。
|
|
96
|
+
* 给「相对 spec」返回「产物 spec」,返回 undefined 表示不改写;
|
|
97
|
+
* 包说明符("pkg" / "@scope/pkg")永不进入该回调。
|
|
98
|
+
*
|
|
99
|
+
* report 的字段(**全部可选**;未发生的事实不写 ⇒ 调用方按 `=== true` 判定):
|
|
100
|
+
* - enumRemoved:TS enum 声明被**整条删除**(仅 `declare enum` —— 环境声明
|
|
101
|
+
* 没有运行时语义)。**运行时 enum 现在是被「合成」而不是被删除** ⇒ 用
|
|
102
|
+
* enumSynthesized 判定(Bug 913)。
|
|
103
|
+
* - enumSynthesized:TS enum 被**合成成运行时对象**(Bug 913)。
|
|
104
|
+
* - namespaceKept:非 declare 的 namespace 被保留(运行时语义)。
|
|
105
|
+
* - exportAssignmentRemoved:`export = X` / `export as namespace X` 被剥除
|
|
106
|
+
* (Bug 446)。
|
|
107
|
+
* - thisParamRemoved:TS 的 `this` 形参被从形参数组里删除(Bug 448)。
|
|
108
|
+
* - typeOnlyImportRemoved:**本地**(相对路径)import 的绑定只在类型位置被
|
|
109
|
+
* 用到(值位置零引用)⇒ 被消掉(与 tsc 的 import elision 同口径)(Bug 445)。
|
|
110
|
+
* - typeOnlyImportKept:值位置的导入**被保留**(绑定有值位置引用,或引用
|
|
111
|
+
* 形态判不准 ⇒ 保守保留)⇒ 产物面应当提示人工确认(Bug 445)。
|
|
112
|
+
* - directivesBefore / directivesAfter / directivesDropped:**剥除前后**的
|
|
113
|
+
* `@nudo:` 指令条数比对(Bug 968 的兜底自检)——不等 ⇒ 有指令随被删语句
|
|
114
|
+
* 一起消失。
|
|
115
|
+
* - ctorParamPropsSuperMissing:**派生类**的构造器参数属性降级时,构造器体
|
|
116
|
+
* **顶层**找不到 `super(...)` 调用 ⇒ 赋值只能落回构造器体开头(原生语义:
|
|
117
|
+
* `super()` 之前访问 `this` ⇒ ReferenceError;源本身即非法 TS)⇒ 产物面
|
|
118
|
+
* 应当提示人工确认(Bug 1071)。
|
|
119
|
+
*/
|
|
120
|
+
type StripOptions = {
|
|
121
|
+
report?: {
|
|
122
|
+
enumRemoved?: boolean;
|
|
123
|
+
enumSynthesized?: boolean;
|
|
124
|
+
namespaceKept?: boolean;
|
|
125
|
+
exportAssignmentRemoved?: boolean;
|
|
126
|
+
thisParamRemoved?: boolean;
|
|
127
|
+
typeOnlyImportRemoved?: boolean;
|
|
128
|
+
typeOnlyImportKept?: boolean;
|
|
129
|
+
directivesBefore?: number;
|
|
130
|
+
directivesAfter?: number;
|
|
131
|
+
directivesDropped?: boolean;
|
|
132
|
+
ctorParamPropsSuperMissing?: boolean;
|
|
133
|
+
};
|
|
134
|
+
resolveSpecifier?: (spec: string) => string | undefined;
|
|
135
|
+
};
|
|
89
136
|
/**
|
|
90
137
|
* 原地剥除 AST 中的 TS-only 语法节点/字段,返回同一棵 AST(便于链式使用)。
|
|
91
138
|
* 不改写任何 loc/start/end;语句删除只影响所在数组,不重排兄弟节点。
|
|
92
|
-
*/
|
|
93
|
-
declare function stripTypes<T extends Node>(ast: T): T;
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* 路径约束栈(Φ)。
|
|
97
139
|
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
140
|
+
* @param source 源码文本(可选)。给了就把**类型注解的源码文本**留在节点上
|
|
141
|
+
* (`nudoTypeText` / `nudoReturnTypeText`,见文件头)——分析面据此读回
|
|
142
|
+
* `.ts` 源的声明类型;不给(migrate 的 keepTs 路径等)则纯剥除。
|
|
143
|
+
* @param opts 可选能力(见 StripOptions):剥除事实回报 + 相对说明符改写。
|
|
144
|
+
* 分析面**不传** ⇒ 行为与旧版逐字一致。
|
|
100
145
|
*/
|
|
101
|
-
|
|
102
|
-
declare function currentPhi(): Phi;
|
|
103
|
-
declare function pushPhi(p: Phi): void;
|
|
104
|
-
declare function popPhi(): void;
|
|
105
|
-
declare function resetPhi(): void;
|
|
106
|
-
/** 在当前 Φ 上合取额外约束,body 结束后恢复 */
|
|
107
|
-
declare function withPhiConstraint(extra: Phi, body: () => void): void;
|
|
108
|
-
declare function describePhi(): string;
|
|
146
|
+
declare function stripTypes<T extends Node>(ast: T, source?: string, opts?: StripOptions): T;
|
|
109
147
|
|
|
110
148
|
/**
|
|
111
149
|
* HOF 关系 Abs:无 body 的外延关系(paramTypes → returnType)的判定、
|
|
112
150
|
* α 替换与应用。类型变量仍是 term var;关系仍是 fn 形状上的外延槽。
|
|
113
151
|
*/
|
|
114
152
|
|
|
115
|
-
declare function createHofCollectCtx(paramNames: ReadonlySet<string>, alphaIds: Iterable<string>): HofCollectCtx;
|
|
116
|
-
/**
|
|
117
|
-
* 仅当 term 是 var 且 id ∈ alphaIds(本次 typeParams)时复用;否则 fresh α。
|
|
118
|
-
* 绝不把调用点具体值/字面量冻进关系。
|
|
119
|
-
*/
|
|
120
|
-
declare function alphaOf(absOrTerm: Abs | Term | undefined, ctx: HofCollectCtx): Term;
|
|
121
|
-
/** 共享输出变量 B:${param}(§5.1 P2 钉死) */
|
|
122
|
-
declare function betaOf(param: string): Term;
|
|
123
|
-
/**
|
|
124
|
-
* 提升写入载体:替换 env.vars map 项,禁止 mutate 共享 Abs。
|
|
125
|
-
* arrival-first:已有 fn/arr 形状 → 拒绝新观测。
|
|
126
|
-
* 返回是否真正写入。
|
|
127
|
-
*/
|
|
128
|
-
declare function promoteParamShape(env: AstEnv, param: string, promotedShape: Shape, opts?: {
|
|
129
|
-
loc?: {
|
|
130
|
-
line: number;
|
|
131
|
-
column: number;
|
|
132
|
-
};
|
|
133
|
-
recordSite?: boolean;
|
|
134
|
-
}): boolean;
|
|
135
|
-
/**
|
|
136
|
-
* 挂载点①:方法派发 miss。receiver 是形参 Identifier 且 shape 为 any/未知,
|
|
137
|
-
* 方法名为 filter/map/reduce/flatMap → 提升为 arr(自身 var)。
|
|
138
|
-
*/
|
|
139
|
-
declare function tryPromoteReceiverAsArr(env: AstEnv, receiverName: string, method: string, loc?: {
|
|
140
|
-
line: number;
|
|
141
|
-
column: number;
|
|
142
|
-
}): Abs | undefined;
|
|
143
|
-
/**
|
|
144
|
-
* for-of 迭代对象提升(applyEach 型):`for (const x of items)`,
|
|
145
|
-
* items 为形参且仍是 any/unknown → arr(自身 var)。不依赖方法名。
|
|
146
|
-
*/
|
|
147
|
-
declare function tryPromoteForOfIteratee(env: AstEnv, iterateeName: string, loc?: {
|
|
148
|
-
line: number;
|
|
149
|
-
column: number;
|
|
150
|
-
}): Abs | undefined;
|
|
151
|
-
/**
|
|
152
|
-
* 挂载点②:CallExpression callee = 形参 Identifier 直接调用 p(x) / p(a,b)。
|
|
153
|
-
* 提升为 fn(paramTypes=[αOf(args)], returnType=B:param)。
|
|
154
|
-
*/
|
|
155
|
-
declare function tryPromoteDirectCall(env: AstEnv, calleeName: string, args: Abs[], loc?: {
|
|
156
|
-
line: number;
|
|
157
|
-
column: number;
|
|
158
|
-
}): Abs | undefined;
|
|
159
|
-
/**
|
|
160
|
-
* 挂载点③:HOF 回调实参。回调是 Identifier ∈ paramNames 且尚未有 fn 形状。
|
|
161
|
-
* 按方法名提升:map/flatMap → fn([αOf(el)], B:param);filter → fn([αOf(el)], bool);
|
|
162
|
-
* reduce → fn([αOf(init), αOf(el)], B:param)。
|
|
163
|
-
*/
|
|
164
|
-
declare function tryPromoteHofCallback(env: AstEnv, cevalName: string, method: string, argAbses: Abs[], loc?: {
|
|
165
|
-
line: number;
|
|
166
|
-
column: number;
|
|
167
|
-
}): Abs | undefined;
|
|
168
153
|
/** deep-ish copy for snapshot(新对象,不是 env.vars 同一引用) */
|
|
169
154
|
declare function snapshotAbs(a: Abs): Abs;
|
|
170
155
|
/**
|
|
@@ -360,6 +345,23 @@ declare function looseEqAbs(a: Abs, b: Abs): boolean | undefined;
|
|
|
360
345
|
/**
|
|
361
346
|
* 对象不变性侧表(freeze/seal/preventExtensions/defineProperty)。
|
|
362
347
|
* WeakMap 侧表:Abs 不可变,写路径读侧表复现 sloppy 静默失败。
|
|
348
|
+
*
|
|
349
|
+
* Invariants(Bug 295):
|
|
350
|
+
* - 枚举视图分**两套口径**,不得混用:
|
|
351
|
+
* - `enumOwnKeys` = **CopyDataProperties 视图**(自有可枚举键,**含**
|
|
352
|
+
* symbol 投影槽)——原生 spread `{...o}` / **对象 rest** / Object.assign
|
|
353
|
+
* 复制自有可枚举 **symbol 键**(node v26 实测:rest 也拷——`rest[
|
|
354
|
+
* Symbol.toStringTag] === 2`;`{...{[Symbol.iterator](){}}}` 仍可迭代 ⇒
|
|
355
|
+
* 引擎的 @@iterator 协议槽正靠这条拷贝链落地)。
|
|
356
|
+
* - `enumOwnStringKeys` = **字符串键视图**(**剔除** symbol 投影槽)——
|
|
357
|
+
* 原生 for-in / Object.keys|values|entries / getOwnPropertyNames /
|
|
358
|
+
* JSON.stringify 只枚举字符串键。
|
|
359
|
+
* **注意**(Bug 1075):`Object.getOwnPropertyDescriptors` **不在**此列——
|
|
360
|
+
* 原生 gOPDs 走 [[OwnPropertyKeys]](**含** symbol 键:结果对象带真
|
|
361
|
+
* symbol 键,`Object.getOwnPropertySymbols(gOPDs(o))` 看得到)。
|
|
362
|
+
* - 报告建议「给 enumOwnKeys 补 symbolKey 过滤」与原生 oracle 冲突:它会
|
|
363
|
+
* 把 symbol 键从 spread/assign/rest 的拷贝链里剔掉 ⇒ 折坏 @@iterator 协议
|
|
364
|
+
* 槽(core 既有 8 处回归)。故按 oracle 拆两套视图,调用点分流。
|
|
363
365
|
*/
|
|
364
366
|
|
|
365
367
|
type ExtState = "nonext" | "sealed" | "frozen";
|
|
@@ -384,6 +386,12 @@ declare function migrateInvariants(from: Abs, to: Abs): void;
|
|
|
384
386
|
* NaN 策略(DEC:显式 NaN 臂):操作数可能为 NaN 时结果为
|
|
385
387
|
* `NaN | number@bounds`。契约 `ge(0).le(100)` 对 NaN 臂诚实报违例;
|
|
386
388
|
* `if (Number.isNaN(n)) return …` 假臂的 `ne(n, NaN)` 事实可排除 NaN 臂。
|
|
389
|
+
*
|
|
390
|
+
* Invariants(Bug 958):min/max 的**区间端点合并按合取/析取分家**——
|
|
391
|
+
* 合取位(min 的 lo / max 的 hi:`min(a,b) ≥ L ⟺ a ≥ L ∧ b ≥ L`)端点值
|
|
392
|
+
* 相同取**更松**(非 strict)的一侧;析取位(max 的 lo / min 的 hi)取
|
|
393
|
+
* **更严**的一侧。取反会产出**不可满足**谓词(`min(x,0) > 0 ∧ ≤ 0`)⇒
|
|
394
|
+
* 证明器 ex falso 放电 ⇒ 契约门禁假绿 + 分支选错臂且 `conf: exact`。
|
|
387
395
|
*/
|
|
388
396
|
|
|
389
397
|
declare function evalMathMethod(name: string, args: Abs[]): Abs | undefined;
|
|
@@ -408,6 +416,26 @@ declare function evalMathMethod(name: string, args: Abs[]): Abs | undefined;
|
|
|
408
416
|
* 侧表派发(getter 读折返回体、setter 写走侧表不误抛 writable:false);
|
|
409
417
|
* 描述符字段语义 = 新建属性缺省 false、已有属性仅显式 false 收紧;
|
|
410
418
|
* open/index 标记与 invariants/accessor 侧表随不可变更新迁移。
|
|
419
|
+
* - Bug 292:描述符字段语义改按 ES2024 10.4.5 ToPropertyDescriptor 的
|
|
420
|
+
* **字段存在性**(HasProperty)——`get: undefined` 仍是「有 get 字段」
|
|
421
|
+
* (⇒ 与 value/writable 共存 → 定抛)、`writable/enumerable/configurable:
|
|
422
|
+
* undefined` ⇒ ToBoolean → false(收紧,不是「缺省保持原状」)。
|
|
423
|
+
* 安装机器实现 ValidateAndApplyPropertyDescriptor(10.4.9):目标已有键
|
|
424
|
+
* 且**不可配置**时,标志/值/访问机制不可变(不可配置 / 枚举改 / 写门改 /
|
|
425
|
+
* 值改 / 数据↔访问器互转 → 重定义失败);目标为**新键**且不可扩展 → 失败。
|
|
426
|
+
* 已有属性的标志**双向**应用描述符显式字段(未指定字段保持当前值)——
|
|
427
|
+
* enumerable:false → enumerable:true 可恢复(此前只单向收紧,永不恢复)。
|
|
428
|
+
* 失败信号分两面:Object 口径定抛 TypeError(applyPropertyDescriptor)、
|
|
429
|
+
* Reflect 口径返 false 不抛(applyPropertyDescriptorVerdict)。
|
|
430
|
+
* - Bug 300:Proxy [[GetOwnProperty]] 陷阱的单一实现
|
|
431
|
+
* (proxyGetOwnPropDescTrap:派发 + ToPropertyDescriptor 非对象 → 定抛 +
|
|
432
|
+
* completePropDescAbs 补全描述符)——Reflect 面在 builtins/reflect.ts
|
|
433
|
+
* 调用;Object 面需在 builtins/object/methods.ts 接线(越界诉求见报告)。
|
|
434
|
+
* - Bug 1074:Proxy [[GetOwnProperty]] 的**靶一致性不变量**(ES2024 10.5.5
|
|
435
|
+
* step 12.f)——靶自有 + 不可配置 + 不可写的数据属性,陷阱描述符的
|
|
436
|
+
* [[Value]] 必须 SameValue 靶上的实际值,否则原生定抛 TypeError
|
|
437
|
+
* (enforceProxyGetOwnPropDescInvariant;口径与 [[Get]] 面的
|
|
438
|
+
* exec/runtime/state.ts enforceProxyGetInvariant 同源)。
|
|
411
439
|
* - Bug 86:tuple 接收者不再静默丢弃——下标键逐位装(增长段 hole、
|
|
412
440
|
* 空描述符清 hole)、length 键截断/延长(非法 RangeError)、
|
|
413
441
|
* {writable:false} length 以 sealed 近似、frozen 相同值重定义放行。
|
|
@@ -420,6 +448,27 @@ declare function evalMathMethod(name: string, args: Abs[]): Abs | undefined;
|
|
|
420
448
|
* - classifyAssignSet(Bug 128)是 Object.assign 逐键 [[Set]] 单一分类:
|
|
421
449
|
* 自有访问器 setter / __proto__ 原型 setter(null|对象设原型、原始值
|
|
422
450
|
* 忽略、抽象 open)/ 自有·继承非可写定抛 / 其余建自有键。
|
|
451
|
+
* - performObjectAssign 是 Object.assign 的**单一实现**(runtime 直接面
|
|
452
|
+
* exec/class/assign.ts 与 second-class 静态面 methods.ts 共用):obj /
|
|
453
|
+
* tuple / brand(原型对象)目标**就地**写并返回同一 Abs(原生引用语义——
|
|
454
|
+
* 别名/语句位可见),prim/boxed 目标的抛错域与降级口径不变。
|
|
455
|
+
* - frozen 目标的抛错门:**只在实际执行 Set(target, key, value, true) 时**
|
|
456
|
+
* 失败(原生 oracle:assign(freeze({}), {}) / assign(freeze({}), null) 不抛,
|
|
457
|
+
* assign(freeze({}), {a:1}) 抛 TypeError)——源零可枚举自有键 ⇒ 不抛;
|
|
458
|
+
* 源键集不可判 ⇒ may-throw(不定抛);键集已知非空 ⇒ 逐键判定(新建键 /
|
|
459
|
+
* 不可写数据属性 / 改原型 ⇒ TypeError,setter 派发 ⇒ 成功)。
|
|
460
|
+
* - sealed / nonext 目标的写门(**obj 与 brand 同规则**):只拒绝**新自有
|
|
461
|
+
* 键**(不可扩展 ⇒ [[Set]] 建键失败 ⇒ TypeError);已有自有可写数据属性 /
|
|
462
|
+
* 自有 setter 照常成功(seal 不改 writable、不禁访问器)。brand 目标的自有
|
|
463
|
+
* 面 = 内层 obj 槽 + 访问器侧表 + owner 类的自有方法/访问器(brandKeyIsNew);
|
|
464
|
+
* 自有键集不可判(内层开箱 / 内建原型品牌无类注册表条目)⇒ 不抛(保守)。
|
|
465
|
+
* frozen brand 仍走 frozenBrandGuard 的整目标拒写门。
|
|
466
|
+
* - Bug 210:Proxy [[OwnPropertyKeys]] 的单一实现(proxyOwnKeysTrapKeys
|
|
467
|
+
* 派发 + enforceProxyOwnKeysInvariant 校验)——重复名 / 非字符串键 /
|
|
468
|
+
* 漏靶的不可配置自有键 / 不可扩展靶的多余键 → 原生定抛 TypeError;
|
|
469
|
+
* 不可判面(抽象键 / 抽象靶键集)→ 不抛(sound 保守)。
|
|
470
|
+
* proxyTargetOwnStringKeys / proxyTargetEnumerableStringKeys 给出靶的
|
|
471
|
+
* 自有字符串键面(gOPN / Object.keys 用;internal·inherited·"@@X" 槽剔除)。
|
|
423
472
|
*
|
|
424
473
|
* 兄弟模块边界:methods.ts(evalObjectMethod)经导出复用安装机器;
|
|
425
474
|
* readProperty 供 json.ts(stringify 读值)。
|
|
@@ -445,6 +494,27 @@ declare function assignSourceSlots(src: Abs): Record<string, {
|
|
|
445
494
|
* Abs 对象原型进 protoTable([[Prototype]] 事实,Bug 67——instanceof 链
|
|
446
495
|
* 终止判定不得把 null 终止链折 true);第二实参 propertiesObject 逐可
|
|
447
496
|
* 枚举键过 ToPropertyDescriptor 安装自有属性(Bug 32/23)。
|
|
497
|
+
* - Bug 323:create 的第二实参按**值**判定——「If properties is not
|
|
498
|
+
* undefined」⇒ 显式 `undefined` 与不传同义(整步跳过,不抛);`null` 抛。
|
|
499
|
+
* - Bug 324:defineProperties 的第二实参走 **ToObject**——null/undefined
|
|
500
|
+
* 抛;其它原始值装箱成零自有可枚举属性的包装器 ⇒ 不定义任何属性、不抛
|
|
501
|
+
* (非空字符串例外:装箱后有下标键 ⇒ 描述符是字符 ⇒ TypeError)。
|
|
502
|
+
* - Bug 291:freeze / seal 落**键级标志**(freeze ⇒ writable+configurable
|
|
503
|
+
* 假;seal ⇒ configurable 假)+ isFrozen / isSealed 的**平凡真**判定
|
|
504
|
+
* (不可扩展 ∧ 每个自有属性不可配置 ∧(数据属性)不可写)。
|
|
505
|
+
* - Bug 301:freeze / seal 对 **Proxy** 走陷阱(preventExtensions + 逐键
|
|
506
|
+
* defineProperty;falsy ⇒ TypeError)。
|
|
507
|
+
* - Bug 308:RegExp 实例的自有 `lastIndex`(gOPN = 「全部自有键」语义)
|
|
508
|
+
* 与 gOPD 的数据描述符(可写、非可枚举、不可配置)。
|
|
509
|
+
* - Bug 315:Object.prototype.toLocaleString 的委派在 object-proto.ts;
|
|
510
|
+
* 本模块的描述符面须与之同口径(gOPDs 的访问器描述符 = {get, set})。
|
|
511
|
+
* - Bug 326:键家族(keys/values/entries)对**自有键集不完备**的对象折
|
|
512
|
+
* partial(标记在 prop flags 侧表)——不得折 exact 空元组。
|
|
513
|
+
* - Bug 1075:gOPDs 的自有键面走 [[OwnPropertyKeys]]——**含 symbol 键**
|
|
514
|
+
* (原生 gOPDs 的结果对象带真 symbol 键)⇒ symbol 投影槽**保留**并带
|
|
515
|
+
* `symbolKey` 标记(字符串键面 Object.keys / gOPN 仍剔除它)。
|
|
516
|
+
* - Bug 1077:不可变原型 Object.prototype 置 **null** 原型**放行**
|
|
517
|
+
* (protoChangeAllowed;置非 null 仍拒——Object 面抛 / Reflect 面 false)。
|
|
448
518
|
* - 未建模方法 → undefined 走通用回退。
|
|
449
519
|
*/
|
|
450
520
|
|
|
@@ -453,6 +523,18 @@ declare function evalObjectMethod(name: string, args: Abs[]): Abs | undefined;
|
|
|
453
523
|
|
|
454
524
|
/**
|
|
455
525
|
* JSON.parse / JSON.stringify
|
|
526
|
+
*
|
|
527
|
+
* Invariants:
|
|
528
|
+
* - **brand 折叠是递归的**(Bug 327):内建 brand(Date / Map / Set / RegExp /
|
|
529
|
+
* Error 族 / TypedArray / 装箱 prim…)的 JSON 值域在**任意深度**折叠——
|
|
530
|
+
* 顶层与对象/数组成员同款(此前白名单只对顶层接收者生效 ⇒ 嵌套 brand 一律
|
|
531
|
+
* 落「may carry BigInt / circular / throwing toJSON」⇒ L1/L2 假红)。
|
|
532
|
+
* - **total ≠ 精确**:值不可知但恒不抛的 brand(TypedArray 家族:元素值未
|
|
533
|
+
* 建模)折 total(值域 partial),**不**折成 "{}"——那会造出自信的错值。
|
|
534
|
+
* - bigint 元素家族(BigInt64Array / BigUint64Array)原生**定抛** TypeError
|
|
535
|
+
* ⇒ 不在 total 集(保持 may-throw 记账)。
|
|
536
|
+
* - reviver(parse)与 replacer(stringify)**两侧口径对称**(Bug 298):
|
|
537
|
+
* callable 回调**真执行**(副作用通道不丢),返回值域保守(unknown)。
|
|
456
538
|
*/
|
|
457
539
|
|
|
458
540
|
/** JSON.parse / stringify:字面量实参真执行折叠;失败硬抛(catch 可吸收) */
|
|
@@ -474,6 +556,22 @@ declare function evalGlobalFn(name: string, args: Abs[]): Abs | undefined;
|
|
|
474
556
|
|
|
475
557
|
/**
|
|
476
558
|
* Array 构造 / Array.* 静态方法
|
|
559
|
+
*
|
|
560
|
+
* Invariants:
|
|
561
|
+
* - Bug 202:`Array.from(用户 iterable)` **实际驱动**用户迭代器(GetIterator
|
|
562
|
+
* + IteratorNext,元素按迭代序取)——与 elemsOf / for-of / spread 同款
|
|
563
|
+
* 协议;迭代器报告 done ⇒ 元素数确切 ⇒ exact 元组。
|
|
564
|
+
* - Bug 195:`Array.isArray` 认**数组视图标注**(markMatchArrayView)的对象
|
|
565
|
+
* ——标签模板对象是冻结的数组 exotic(原生 true);RegExp exec/match
|
|
566
|
+
* 结果同款(原生亦是真数组)。
|
|
567
|
+
* - Bug 294:array-like 读数(length / 逐索引)**先经访问器侧表**
|
|
568
|
+
* (accessorReadDomain)——真 getter 住侧表、shape 里只有占位槽;
|
|
569
|
+
* 裸读槽 ⇒ length 被当 undefined(折空数组)+ getter 副作用消失。
|
|
570
|
+
* 每次 Array.from 读一次 length / 每个索引(与原生同款)。
|
|
571
|
+
* - Bug 296:`Array.from(items, mapFn, thisArg)` 的**第三实参**透传给
|
|
572
|
+
* 回调(此前丢弃 ⇒ 回调 this 恒 undefined ⇒ 假抛 / 计数器归零)。
|
|
573
|
+
* - Bug 330:Array.prototype.{toString,toLocaleString,join} 接收者为
|
|
574
|
+
* **nullish** ⇒ 定抛 TypeError(ToObject)——不记抛 ⇒ L2 门禁假绿。
|
|
477
575
|
*/
|
|
478
576
|
|
|
479
577
|
declare function makeArrayCtorAbs(args: Abs[]): Abs;
|
|
@@ -488,6 +586,18 @@ declare function evalArrayStatic(name: string, args: Abs[]): Abs | undefined;
|
|
|
488
586
|
* coercer 槽 total(ToPrimitive 恒得 "[object Object]" → Invalid Date);其余
|
|
489
587
|
* 抽象 may(coercer 可能产 Symbol/BigInt)。多参形式每个实参直接 ToNumber。
|
|
490
588
|
* Bug 62:setter 实参逐个 ToNumber 校验;getter/toString 族值域建模。
|
|
589
|
+
*
|
|
590
|
+
* Invariants:
|
|
591
|
+
* - Bug 297:Date 的 time value 是**可写槽**(构造期写入 brand shape 的 tv
|
|
592
|
+
* facet)。`Date.prototype.set*` 族不再是空操作——按规范语义回写该槽
|
|
593
|
+
* (MakeDay/MakeTime 归一化、月日溢出、TimeClip 越界 → Invalid Date,与
|
|
594
|
+
* 原生逐条同口径:实现走**宿主 Date**,两位年映射差异(构造器 1900 偏移 vs
|
|
595
|
+
* setter 不偏移)自动对齐)。**实参不可判定 → 作废该槽**(精确渲染面随之
|
|
596
|
+
* 降级为 may-throw,绝不给过期日期)。getTime/valueOf 与 toISOString 读
|
|
597
|
+
* 同一槽 ⇒ 读面 / 投影面(JSON.stringify)同源,不会自相矛盾。
|
|
598
|
+
* - Bug 319:`toJSON` 单列一档——Invalid Date(tv=NaN)→ **null 字面量**
|
|
599
|
+
* (原生返回 null,不是字符串);tv 已知且有效 → ISO 串;tv 不可知 → 保守
|
|
600
|
+
* `string | null` 域(不再是恒 string)。
|
|
491
601
|
*/
|
|
492
602
|
|
|
493
603
|
declare function evalDateCtor(args: Abs[]): Abs;
|
|
@@ -496,6 +606,14 @@ declare function evalDateMethod(name: string, recv: Abs, args: Abs[]): Abs | und
|
|
|
496
606
|
|
|
497
607
|
/**
|
|
498
608
|
* RegExp 构造 / brand / 实例方法
|
|
609
|
+
*
|
|
610
|
+
* Invariants:
|
|
611
|
+
* - RegExpExecArray 原生是**数组 exotic**(IsArray = true,继承
|
|
612
|
+
* Array.prototype)⇒ 匹配结果既有**数组方法面**(join / slice / map…,
|
|
613
|
+
* 经 markMatchArrayView 侧表 + 数组方法派发),也有**可迭代面**
|
|
614
|
+
* (spread / for-of / 数组解构)。后者经「@@iterator 槽(非枚举)+
|
|
615
|
+
* 元素侧表」给出(Bug 290)——形状仍是 obj(容器 arr/tuple 无侧槽,
|
|
616
|
+
* #136 的槽读面依赖它)。
|
|
499
617
|
*/
|
|
500
618
|
|
|
501
619
|
declare function evalRegExpCtor(args: Abs[]): Abs;
|
|
@@ -566,10 +684,18 @@ declare function isObjectProtoBrand(a: Abs | undefined): boolean;
|
|
|
566
684
|
* 与 new 分派在 dispatch.ts。
|
|
567
685
|
*/
|
|
568
686
|
|
|
569
|
-
|
|
687
|
+
/**
|
|
688
|
+
* 命名空间静态分派。Bug 311:thisVal = 静态方法值的 this 绑定(成员读出的
|
|
689
|
+
* 静态方法被单独调用时的接收者,如 `Promise.resolve.call(null, 1)`);
|
|
690
|
+
* 缺席 = 直接命名空间调用(this ≡ 命名空间构造器,合法)。
|
|
691
|
+
*/
|
|
692
|
+
declare function evalNamespaceCall(ns: string, method: string, args: Abs[], thisVal?: Abs): Abs | undefined;
|
|
693
|
+
|
|
694
|
+
declare function isErrorCtorName(name: string | undefined): boolean;
|
|
570
695
|
|
|
571
696
|
/**
|
|
572
|
-
* Error 家族(
|
|
697
|
+
* Error 家族(isErrorCtorName/errorBrandAbs;构造器名集合在
|
|
698
|
+
* algebra/error-names.ts 叶子)+ 宿主构造器
|
|
573
699
|
* 实参校验谓词(sumHasPrimMember/isNullishLit/enforceCanBeHeldWeakly/
|
|
574
700
|
* isDefinitelyUndefinedArg)+ Proxy 构造(makeProxyAbs)。
|
|
575
701
|
*
|
|
@@ -591,12 +717,11 @@ declare function evalNamespaceCall(ns: string, method: string, args: Abs[]): Abs
|
|
|
591
717
|
* 靶形态);target/handler 引用挂 match-iter 侧表(Bug 57/71 陷阱派发)。
|
|
592
718
|
*/
|
|
593
719
|
|
|
594
|
-
declare function isErrorCtorName(name: string | undefined): boolean;
|
|
595
720
|
/**
|
|
596
721
|
* Error brand:shape 带 name/message(字面量 message 保精确)。
|
|
597
722
|
* AggregateError(errors, message[, options]):message 在第二实参,errors
|
|
598
|
-
* 挂 .errors
|
|
599
|
-
*
|
|
723
|
+
* 挂 .errors(原生是实参数组**副本**——见 iterableListCopy);options.cause
|
|
724
|
+
* 挂 .cause(**仅当 options 真有 cause 键**才装槽——见 Bug 316)。
|
|
600
725
|
* $new 的 new Error 路径共用——catch 形参成员访问可解。
|
|
601
726
|
*/
|
|
602
727
|
declare function errorBrandAbs(name: string, args: Abs[]): Abs;
|
|
@@ -610,10 +735,13 @@ declare function errorBrandAbs(name: string, args: Abs[]): Abs;
|
|
|
610
735
|
* - 两入口是内建构造/实例方法的总分派(exec $new 宿主分支与 Abs 面
|
|
611
736
|
* evalBuiltinNew 共用各域 builder;未建模名/方法 → undefined 走通用
|
|
612
737
|
* 回退,不得折精确值)。
|
|
613
|
-
* - TA set
|
|
614
|
-
* off+srcLen > tgtLen
|
|
615
|
-
*
|
|
738
|
+
* - TA set 四段校验(Bug 38/304/305):ToIndex(offset) + ToObject(source) +
|
|
739
|
+
* off+srcLen > tgtLen 越界 + 源/目标内容类型一致(number vs bigint)+
|
|
740
|
+
* 逐元素 ToNumber/ToBigInt 转换——长度读 binary 域构造入槽的 length 槽
|
|
741
|
+
* (makeTypedArrayAbs 数字形态)/ taSetSourceLength(tuple 元数/字符串
|
|
616
742
|
* 长度/TA 源槽/装箱折 0);成功恒返 undefined,元素拷贝值域不建模。
|
|
743
|
+
* 原生报错序(node v26):越界(RangeError)→ 内容类型(TypeError)→
|
|
744
|
+
* 元素转换(TypeError/SyntaxError)——越界不可判时后两段只记 may。
|
|
617
745
|
* - ArrayBuffer.resize(Bug 39):resizable 槽 false 字面量定抛
|
|
618
746
|
* TypeError;成功臂 byteLength 槽**原地更新**($set 引用语义惯例——
|
|
619
747
|
* 别名同步);transfer/grow/slice 不在此扩 scope。
|
|
@@ -621,11 +749,24 @@ declare function errorBrandAbs(name: string, args: Abs[]): Abs;
|
|
|
621
749
|
* viewLen 定抛 RangeError;读返回域按元素类型(bigint 家族 → bigint)。
|
|
622
750
|
* - Error 家族 toString/toLocaleString = `${name}: ${message}`(槽已
|
|
623
751
|
* 建模,空 message 只返 name);Map/Set 方法族落 collections 条目机,
|
|
624
|
-
* 迭代三件套经 iterator.ts 协议对象(
|
|
625
|
-
*
|
|
752
|
+
* 迭代三件套经 iterator.ts 协议对象(collectionIteratorFor——**live
|
|
753
|
+
* 视图**,Bug 198:新增条目被访问、删除条目被跳过;快照与 live 同投影,
|
|
754
|
+
* live 迭代器不登记静态元素侧表),Set ES2025 方法族先过 binary 域 set-like
|
|
755
|
+
* 校验再 setMethodFold
|
|
626
756
|
* (不可折 → 集合运算诚实 unknown / is* 抽象 boolean)。
|
|
627
757
|
*/
|
|
628
758
|
|
|
759
|
+
/**
|
|
760
|
+
* Bug 198:Map/Set 迭代三件套(keys / values / entries)= **live 视图**的
|
|
761
|
+
* 协议对象——原生迭代器持条目指针:迭代期间**新增**的条目被访问、**删除**的
|
|
762
|
+
* 条目被跳过(`const it = m.keys(); it.next(); m.delete("b"); it.next().done`
|
|
763
|
+
* 原生 true,引擎快照口径折 false)。
|
|
764
|
+
*
|
|
765
|
+
* 投影与 live 视图的**同口径实现**都在 `builtins/error/iterator.ts` 的
|
|
766
|
+
* `collectionIteratorFor`(project 闭包只有一份:Map 的 keys/values 给
|
|
767
|
+
* 键/值,Set 的 entries 给 [el,el] 元组)——本文件此前自建了一份等价实现
|
|
768
|
+
* (绕开 iterator.ts 的投影错配),S17 已改回**直调**。
|
|
769
|
+
*/
|
|
629
770
|
/** new X(...) */
|
|
630
771
|
declare function evalBuiltinNew(className: string, args: Abs[]): Abs | undefined;
|
|
631
772
|
/** brand 实例方法(Date/RegExp/Map/Set/Error 家族/装箱拆箱后的 prim 面在外层) */
|
|
@@ -679,6 +820,17 @@ declare function stringOfSymbol(a: Abs): Abs;
|
|
|
679
820
|
|
|
680
821
|
/**
|
|
681
822
|
* Object.prototype 成员(hasOwnProperty / isPrototypeOf / toString / …)
|
|
823
|
+
*
|
|
824
|
+
* Invariants:
|
|
825
|
+
* - toString 走 typeTagOf 的**标签面**("[object X]");toLocaleString 走
|
|
826
|
+
* **委派面**(Bug 315:node 实测 Object.prototype.toLocaleString 调
|
|
827
|
+
* 接收者的 toString()——**不**调接收者自有的 toLocaleString;接收者没有
|
|
828
|
+
* 可调用的 toString(null 原型对象)⇒ TypeError)。委派面的「读接收者
|
|
829
|
+
* toString 成员」由 exec 侧(member.ts)注册钩子提供(避免
|
|
830
|
+
* builtins↔exec 的 import 环)。
|
|
831
|
+
* - Bug 325:fn 形状的标签按**函数种类**分(Function / AsyncFunction /
|
|
832
|
+
* GeneratorFunction / AsyncGeneratorFunction)——种类戳由 transpile 侧
|
|
833
|
+
* $fnVal opts.kind 打。
|
|
682
834
|
*/
|
|
683
835
|
|
|
684
836
|
/**
|
|
@@ -736,10 +888,15 @@ type Slot = {
|
|
|
736
888
|
/** ES 规范数组下标(无前导零、< 2^32-1);非规范键返回 undefined */
|
|
737
889
|
declare function canonicalArrayIndex(v: unknown): number | undefined;
|
|
738
890
|
/**
|
|
739
|
-
* ES ToPropertyKey
|
|
891
|
+
* ES ToPropertyKey 的折叠:null→"null"、undefined→"undefined"、
|
|
740
892
|
* true/false→"true"/"false"、number/bigint/string → String(v)(ToString)。
|
|
741
893
|
* 必须看 term——litValue 把 lit(undefined) 吞成哨兵 undefined。
|
|
742
894
|
* 抽象 / symbol 返回 undefined(调用方保守处理)。
|
|
895
|
+
*
|
|
896
|
+
* Bug 383:**对象键**也走 ToPropertyKey(ToPrimitive(string) → ToString)——
|
|
897
|
+
* 钩子**真调用**(与 Bug 381 的钩子调用面同口径:副作用与 throw 域随之而来)。
|
|
898
|
+
* 修前只认字面量 term ⇒ 对象键落「抽象键」臂 ⇒ 写被静默丢弃、键的强制
|
|
899
|
+
* 转换副作用全丢。
|
|
743
900
|
*/
|
|
744
901
|
declare function propertyKeyOf(a: Abs | undefined): string | undefined;
|
|
745
902
|
type ObjShape = {
|
|
@@ -783,6 +940,12 @@ declare function joinObjects(a: Abs, b: Abs): Abs;
|
|
|
783
940
|
/** 值级 join:同型双字面量保留为枚举 sum;其余 prim 同型收成 path */
|
|
784
941
|
declare function joinValues(a: Abs, b: Abs): Abs;
|
|
785
942
|
declare function makeSum(a: Abs, b: Abs): Abs;
|
|
943
|
+
/**
|
|
944
|
+
* 结构键的最小面(join 去重 / 槽相等 / env 声明去重共用)。
|
|
945
|
+
* 实现见 abs-key.ts(shape × term × pred 的单一序列化);本函数保持
|
|
946
|
+
* **纯结构**契约——fn 实现身份不进键(env-loader 的「同一声明」去重依赖
|
|
947
|
+
* 结构相等)。makeSum/flattenSum 的去重键另有 sumDedupeKey 附加 impl 身份。
|
|
948
|
+
*/
|
|
786
949
|
declare function absShapeKey(a: Abs, seen?: Set<object>): string;
|
|
787
950
|
type FnAbs = Abs & {
|
|
788
951
|
shape: {
|
|
@@ -798,6 +961,7 @@ type FnAbs = Abs & {
|
|
|
798
961
|
declare function fnOf(params: string[], name?: string): Abs;
|
|
799
962
|
/**
|
|
800
963
|
* 函数 join:签名并(重载),禁止 (A|C)→(B|D)。
|
|
964
|
+
* 同名同参且**可观察元数据全同** → 同一值(折叠成 a);否则 sum。
|
|
801
965
|
*/
|
|
802
966
|
declare function joinFunctions(a: Abs, b: Abs): Abs;
|
|
803
967
|
/** 通用 join:分派到对象/函数/值 */
|
|
@@ -1008,24 +1172,68 @@ declare function formatAbsMultiline(a: Abs, label?: string): string;
|
|
|
1008
1172
|
* - ObjectPattern / ArrayPattern → 求值占位 `_p{i}`;契约面 = 顶层绑定名
|
|
1009
1173
|
* (对象属性 / 数组元素 Identifier)。嵌套 pattern 的绑定名标 `nested`,
|
|
1010
1174
|
* 消费方可显式降级(C4.5 param-mismatch / 不执法)。
|
|
1175
|
+
*
|
|
1176
|
+
* Bug 479:`tsType` 携带**源码里的 TS 声明类型文本**(剥除 pass 留下的旁路
|
|
1177
|
+
* `nudoTypeText`)——`.ts` 源的形参据此不是「无约束 any」。
|
|
1178
|
+
*
|
|
1179
|
+
* Bug 388:`kind: "pattern"` 同时覆盖 `ObjectPattern` 与 `ArrayPattern`
|
|
1180
|
+
* ⇒ 模型层**记录模式种类**(`patternKind`),渲染层(签名面)与执法层
|
|
1181
|
+
* (契约寻址)才能区分「按属性键寻址」与「按下标寻址」。
|
|
1182
|
+
*
|
|
1183
|
+
* Bug 397:TS 的 `this: T` 是**接收者标注**,不是运行时形参(Babel AST 里
|
|
1184
|
+
* 就是 `Identifier("this")`)⇒ 不进形参表、不占实参位。
|
|
1185
|
+
*
|
|
1186
|
+
* Bug 399:默认形参**可省略** ⇒ 形参表带 `optional` 标记(消费侧据此算
|
|
1187
|
+
* 必选元数,不再靠名字后缀猜)。
|
|
1011
1188
|
*/
|
|
1012
1189
|
type FormalParam = {
|
|
1013
1190
|
kind: "id";
|
|
1014
1191
|
name: string;
|
|
1015
1192
|
index: number;
|
|
1193
|
+
tsType?: string;
|
|
1194
|
+
/** 该形参位可省略(Bug 399):true = 不计入必选元数 */
|
|
1195
|
+
optional?: boolean;
|
|
1016
1196
|
} | {
|
|
1017
1197
|
kind: "default";
|
|
1018
1198
|
name: string;
|
|
1019
1199
|
index: number;
|
|
1200
|
+
tsType?: string;
|
|
1201
|
+
/** 默认形参恒可省略(Bug 399) */
|
|
1202
|
+
optional?: boolean;
|
|
1020
1203
|
} | {
|
|
1021
1204
|
kind: "rest";
|
|
1022
1205
|
name: string;
|
|
1023
1206
|
display: string;
|
|
1024
1207
|
index: number;
|
|
1208
|
+
tsType?: string;
|
|
1209
|
+
/** rest 形参恒可省略(Bug 399) */
|
|
1210
|
+
optional?: boolean;
|
|
1211
|
+
/**
|
|
1212
|
+
* S6-1008:rest 形参的**元数信息**(本函数接受的实参个数域)。
|
|
1213
|
+
*
|
|
1214
|
+
* - `min`:**必选元数**——rest 之前**必选**形参的个数(默认形参 /
|
|
1215
|
+
* 带默认值的解构形参可省略 ⇒ 不计;TS 的 `this` 接收者标注不是形参
|
|
1216
|
+
* ⇒ 不计)。
|
|
1217
|
+
* - `variadic`:**变长**——rest 吸收 0..n 个实参 ⇒ 元数**无上界**
|
|
1218
|
+
* (「真正变长」由 core 建模 ⇒ 消费方不再各自按名字后缀猜)。
|
|
1219
|
+
*
|
|
1220
|
+
* 缺省 = undefined(未建模 ⇒ 消费方按既有「定长」口径处理)。
|
|
1221
|
+
*/
|
|
1222
|
+
arity?: {
|
|
1223
|
+
min: number;
|
|
1224
|
+
variadic: true;
|
|
1225
|
+
};
|
|
1025
1226
|
} | {
|
|
1026
1227
|
kind: "pattern";
|
|
1027
1228
|
/** 求值/签名占位名(generalize 与 dts 用) */
|
|
1028
1229
|
placeholder: string;
|
|
1230
|
+
/**
|
|
1231
|
+
* 模式种类(Bug 388):
|
|
1232
|
+
* - `"object"` = 对象解构(契约面按**属性键**寻址)
|
|
1233
|
+
* - `"array"` = 数组解构(契约面按**元素下标**寻址)
|
|
1234
|
+
* 缺省 = `"object"`(历史口径)。
|
|
1235
|
+
*/
|
|
1236
|
+
patternKind?: "object" | "array";
|
|
1029
1237
|
/** 顶层可表达绑定名(侧车契约面) */
|
|
1030
1238
|
bound: string[];
|
|
1031
1239
|
/**
|
|
@@ -1033,6 +1241,11 @@ type FormalParam = {
|
|
|
1033
1241
|
* 投影必须用属性键 a(Abs 对象只有 slot a)。
|
|
1034
1242
|
*/
|
|
1035
1243
|
propKey: Record<string, string>;
|
|
1244
|
+
/**
|
|
1245
|
+
* 数组解构:绑定名 → **元素下标**(`[a, b]` ⇒ a→0、b→1)。
|
|
1246
|
+
* 对象解构不用这张表(对象解构按属性键寻址,见 `propKey`)。
|
|
1247
|
+
*/
|
|
1248
|
+
boundIndex?: Record<string, number>;
|
|
1036
1249
|
/** 仅嵌套内出现、顶层不可单独表达的名(降级用) */
|
|
1037
1250
|
nested: string[];
|
|
1038
1251
|
/**
|
|
@@ -1041,6 +1254,10 @@ type FormalParam = {
|
|
|
1041
1254
|
*/
|
|
1042
1255
|
nestedPaths: string[];
|
|
1043
1256
|
index: number;
|
|
1257
|
+
/** TS 声明类型文本(.ts 源;缺省 = 无注解) */
|
|
1258
|
+
tsType?: string;
|
|
1259
|
+
/** 带默认值的解构形参(`{ a } = {}`)可省略(Bug 399) */
|
|
1260
|
+
optional?: boolean;
|
|
1044
1261
|
};
|
|
1045
1262
|
type AstParam = {
|
|
1046
1263
|
type: string;
|
|
@@ -1048,6 +1265,8 @@ type AstParam = {
|
|
|
1048
1265
|
left?: AstParam;
|
|
1049
1266
|
right?: unknown;
|
|
1050
1267
|
argument?: AstParam;
|
|
1268
|
+
/** Bug 479:剥除 pass 留下的类型注解文本旁路 */
|
|
1269
|
+
nudoTypeText?: string;
|
|
1051
1270
|
properties?: Array<{
|
|
1052
1271
|
key?: AstParam;
|
|
1053
1272
|
value?: AstParam;
|
|
@@ -1063,6 +1282,9 @@ declare function formalParamDisplayNames(formals: FormalParam[]): string[];
|
|
|
1063
1282
|
* 签名展示名(C4.1 #64):解构形参渲染为 `{ grade, findings }`,
|
|
1064
1283
|
* 不落回求值占位 `_p0`——否则读签名的人以为没有契约。
|
|
1065
1284
|
* 求值/内部键仍用 formalParamDisplayNames(`_p0`)。
|
|
1285
|
+
*
|
|
1286
|
+
* Bug 388:数组解构渲染为 `[ x, y ]`(与源码的解构形态一致)——
|
|
1287
|
+
* 此前对象/数组解构一律渲染 `{ … }`,数组解构的签名面**看得出是对象**。
|
|
1066
1288
|
*/
|
|
1067
1289
|
declare function formalParamSignatureNames(formals: FormalParam[]): string[];
|
|
1068
1290
|
/** 侧车契约可绑定的参数名全集 */
|
|
@@ -1076,16 +1298,26 @@ declare function contractParamNameSet(formals: FormalParam[]): Set<string>;
|
|
|
1076
1298
|
* 多段(field 为展示用点连接串)。平铺精确匹配必须先于任何点路径解析:
|
|
1077
1299
|
* 源键 'a.b' 与路径 'a.b' 不可歧义——平铺胜。
|
|
1078
1300
|
* - 未命中 → undefined(C4.5 param-mismatch)
|
|
1301
|
+
*
|
|
1302
|
+
* Bug 388 / 392:命中**数组解构**的顶层 bound 名时,契约面按**元素下标**
|
|
1303
|
+
* 寻址(`[a, b]` 的 `a` 是下标 0 的元素),**不是**属性键 ⇒ 返回
|
|
1304
|
+
* `fieldIndex`(下标)且**不给** `fieldPath`(fieldPath 是对象 slot 投影路径,
|
|
1305
|
+
* 对数组无意义)。执法侧按 `fieldIndex` 投影实参的元素。
|
|
1079
1306
|
*/
|
|
1080
1307
|
declare function locateContractParam(formals: FormalParam[], contractName: string): {
|
|
1081
1308
|
index: number;
|
|
1082
1309
|
field?: string;
|
|
1083
1310
|
fieldPath?: string[];
|
|
1084
1311
|
rest?: boolean;
|
|
1312
|
+
/** 数组解构:契约命中的**元素下标**(对象解构无此字段) */
|
|
1313
|
+
fieldIndex?: number;
|
|
1085
1314
|
} | undefined;
|
|
1086
1315
|
|
|
1087
1316
|
/**
|
|
1088
1317
|
* Abs 键 / α-rename(从 generalize.ts 拆出的纯结构变换)。
|
|
1318
|
+
*
|
|
1319
|
+
* 结构键的唯一实现在 abs-key.ts(shape × term × pred);本模块只保留
|
|
1320
|
+
* generalize 侧需要的能力:α-rename、自由变元收集、instantiate 记忆键。
|
|
1089
1321
|
*/
|
|
1090
1322
|
|
|
1091
1323
|
/** 公开:收集 Abs 自由 term 变元(dts 泛型投影 / α 作用域判定复用 L2 基建)。 */
|
|
@@ -1138,6 +1370,15 @@ type PolyFn = {
|
|
|
1138
1370
|
}>;
|
|
1139
1371
|
/** body 内对该形参的应用点(check/hover/dts 用) */
|
|
1140
1372
|
hofSites?: HofSite[];
|
|
1373
|
+
/**
|
|
1374
|
+
* Bug 389:本次求值被 **env 门禁**挡下(源码声明了 `@nudo:env`,但那个 env
|
|
1375
|
+
* **没解析出全局** ⇒ 无注入 ⇒ 函数体 fail-closed ⇒ 符号面 conf=opaque)。
|
|
1376
|
+
*
|
|
1377
|
+
* 门禁本身是对的(不注入就跑 ⇒ 宿主调用会假抛),但「因门禁而 opaque」**不
|
|
1378
|
+
* 是**「路径没覆盖」⇒ 诊断层不得把它当成「已解释」(否则唯一能提示「推断
|
|
1379
|
+
* 失败」的 `nudo:unknown-inference` 恰好在用户把 env 名写错时被吞掉)。
|
|
1380
|
+
*/
|
|
1381
|
+
envGated?: boolean;
|
|
1141
1382
|
};
|
|
1142
1383
|
declare function extractFn(source: string, fnName: string, fileAst?: ReturnType<typeof parseSource>): {
|
|
1143
1384
|
params: string[];
|
|
@@ -1162,9 +1403,6 @@ declare function generalizeFromAst(fnName: string, source: string, opts?: {
|
|
|
1162
1403
|
* runTranspiled;对象身份进 memo 键(调用方同文件内复用同一对象) */
|
|
1163
1404
|
inject?: RunTranspiledOptions;
|
|
1164
1405
|
}): PolyFn | undefined;
|
|
1165
|
-
declare function generalizeAll(source: string, opts?: {
|
|
1166
|
-
budget?: LeakBudget;
|
|
1167
|
-
}): PolyFn[];
|
|
1168
1406
|
/**
|
|
1169
1407
|
* 列出源码中的顶层函数名。
|
|
1170
1408
|
* 与 scan.listTopFunctions 对齐:解 export default / export const 箭头与函数表达式。
|
|
@@ -1174,8 +1412,17 @@ declare function listFunctionNames(source: string): string[];
|
|
|
1174
1412
|
/**
|
|
1175
1413
|
* 按 assume 集合构造实参:被 assume 的参数给带约束的符号,其余 any
|
|
1176
1414
|
* (design-cli-semantics §2:入口无约束 = any,不是 unknown)。
|
|
1415
|
+
*
|
|
1416
|
+
* Bug 976(core 半):被 assume 的形参的 pred 此前被**写死**成 `x > 0`——
|
|
1417
|
+
* 用户写 `--assume 'x>-5'` 时,写死的界**更强**(`x>-5 ∧ x>0 ⇒ x>0`)⇒
|
|
1418
|
+
* 引擎按 `x>0` 剪枝 ⇒ 观察面给出比用户声明**更窄**的结果(说谎)。
|
|
1419
|
+
* 现在:**用户声明的界**(`bounds`:形参名 → Pred)直接落进形参的 pred;
|
|
1420
|
+
* 没有声明界时**不写界**(不替用户发明一个更强的默认界)——Φ(CLI 侧)
|
|
1421
|
+
* 是界的唯一来源。
|
|
1177
1422
|
*/
|
|
1178
|
-
declare function buildArgsFromAssume(source: string, fnName: string, assumeIds: Set<string
|
|
1423
|
+
declare function buildArgsFromAssume(source: string, fnName: string, assumeIds: Set<string>,
|
|
1424
|
+
/** 用户声明的界(形参名 → Pred);缺省 = 不写界 */
|
|
1425
|
+
bounds?: ReadonlyMap<string, Pred>): Abs[];
|
|
1179
1426
|
|
|
1180
1427
|
/**
|
|
1181
1428
|
* CheckOptions — 从 check.ts 拆出的纯类型,打断 check ↔ check-memo/may-throw 环。
|
|
@@ -1204,9 +1451,14 @@ type CheckOptions = {
|
|
|
1204
1451
|
/**
|
|
1205
1452
|
* L2 入口 may-throw 执法档(design-cli-semantics §3)。
|
|
1206
1453
|
* error(默认)| warning | off。仅作用于 export/default/CJS 入口函数。
|
|
1454
|
+
*
|
|
1455
|
+
* 同时是该 L2 族的**总闸**:模块装载期必抛(`nudo:module-throw`,顶层
|
|
1456
|
+
* 无条件 `throw` ⇒ 模块未被分析)也按此档执法 / 静默 —— 零 FP 语料库
|
|
1457
|
+
* (check-real-packages 的 `entryThrows: "off"`)因此不受新码影响。
|
|
1207
1458
|
*/
|
|
1208
1459
|
entryThrows?: "error" | "warning" | "off";
|
|
1209
|
-
/** L2 --ignore-throws:按 throws 类型名过滤;不吞 L1
|
|
1460
|
+
/** L2 --ignore-throws:按 throws 类型名过滤;不吞 L1。
|
|
1461
|
+
* `nudo:module-throw` 同样消费:句法上判得出的抛出类型名被 ignore 即放行。 */
|
|
1210
1462
|
ignoreThrows?: string[];
|
|
1211
1463
|
/** 宿主已求值的依赖导出表(specifier → AbsModuleExports);
|
|
1212
1464
|
* B 与解释路径共用——import/require 按表解析(CLI 经
|
|
@@ -1225,6 +1477,17 @@ type CheckOptions = {
|
|
|
1225
1477
|
* 入口 may-throw(L2)不评估。调用点参数义务(scan)不受影响。
|
|
1226
1478
|
*/
|
|
1227
1479
|
skips?: ReadonlyMap<string, Abs | null>;
|
|
1480
|
+
/**
|
|
1481
|
+
* 外部调用点证据(Bug 366):`--from` 采集到的**跨文件**调用点记录。
|
|
1482
|
+
*
|
|
1483
|
+
* drift 判定的「今日域」证据此前**只**来自 checkSource 评估被检查文件
|
|
1484
|
+
* 自身时产生的 AbsCallRecord ⇒ 调用点在别的文件里时,`--from` 写出的
|
|
1485
|
+
* 生成段永远判不出陈旧(假绿)。本字段把跨文件证据接进同一条判定通道。
|
|
1486
|
+
*
|
|
1487
|
+
* 形状 = core 公共导出 AbsCallRecord(fnName = **被调方的导出名**;
|
|
1488
|
+
* callLoc 省略 = 跨文件调用点在本文件内无位置)。
|
|
1489
|
+
*/
|
|
1490
|
+
from?: readonly AbsCallRecord[];
|
|
1228
1491
|
};
|
|
1229
1492
|
|
|
1230
1493
|
/**
|
|
@@ -1236,6 +1499,16 @@ type CheckOptions = {
|
|
|
1236
1499
|
*/
|
|
1237
1500
|
|
|
1238
1501
|
declare function resetCheckSourceMemo(): void;
|
|
1502
|
+
/**
|
|
1503
|
+
* ⚠ `checkDepsFingerprint` 已删除(Bug 1139 修复线引入的副作用):
|
|
1504
|
+
* 指纹的 **ambient 侧车探测**必须与「分析读」区分(`autoBind:false` 下
|
|
1505
|
+
* 不可读的 ambient 侧车**不得**让门禁变红)⇒ 探测要走**未经降级闸**的
|
|
1506
|
+
* 推测性 loader,并受 `sidecarAutoBindAllowed` 约束 ⇒ 调用点必须直接调
|
|
1507
|
+
* `loadModuleDepsFingerprint`(带上 ambient 选项)⇒ 本包装器(无法传
|
|
1508
|
+
* ambient 选项)失去唯一用途 ⇒ 删。
|
|
1509
|
+
*
|
|
1510
|
+
* `loadModuleDepsFingerprint` 见 `load-deps-fp.ts`。
|
|
1511
|
+
*/
|
|
1239
1512
|
/** `*.nudo.js` 变更后定向逐出依赖它的整文件 check 缓存。查找与索引同走 stablePathKey */
|
|
1240
1513
|
declare function evictCheckSourceMemoForPaths(paths: string[]): number;
|
|
1241
1514
|
|
|
@@ -1277,7 +1550,7 @@ declare function checkSource(filePath: string, source: string, phi?: Phi, opts?:
|
|
|
1277
1550
|
*/
|
|
1278
1551
|
|
|
1279
1552
|
type FnDirectiveScope = {
|
|
1280
|
-
/** 绑定名:`f` / `C.m` / `default` / `<anonymous>` */
|
|
1553
|
+
/** 绑定名:`f` / `C.m` / `C.static.m` / `default` / `<anonymous>` */
|
|
1281
1554
|
name: string;
|
|
1282
1555
|
node: Node;
|
|
1283
1556
|
/** 该函数的前导注释块(comment.value 原文,文档序) */
|
|
@@ -1287,13 +1560,34 @@ type FnDirectiveScope = {
|
|
|
1287
1560
|
/** 与 commentTexts 对齐的注释起始行号 */
|
|
1288
1561
|
commentStartLines: number[];
|
|
1289
1562
|
startLine: number;
|
|
1563
|
+
/**
|
|
1564
|
+
* 词法嵌套深度:0 = 顶层函数 / 类成员;每进入一层函数体 +1。
|
|
1565
|
+
*
|
|
1566
|
+
* Bug 424:scope 名**不唯一**(同名遮蔽函数 / 嵌套函数)⇒「按名 + 文档序
|
|
1567
|
+
* 首个命中」会让**内层**同名函数抢走导出函数的注释块 ⇒ L2 门禁假绿 / 假红。
|
|
1568
|
+
* ⇒ 按名查找取**最浅**(depth 最小)的那个。
|
|
1569
|
+
*/
|
|
1570
|
+
depth?: number;
|
|
1571
|
+
/** 宿主名(类名 / 外层函数名);顶层为 undefined */
|
|
1572
|
+
owner?: string;
|
|
1290
1573
|
};
|
|
1291
1574
|
/**
|
|
1292
1575
|
* 全量 Function 站点:nested function、class method、object method 均可见。
|
|
1293
1576
|
* 函数级指令绑「其前导注释块」;注释若带在非函数语句上则不绑(不留孤儿指令)。
|
|
1294
1577
|
*/
|
|
1295
1578
|
declare function listFnDirectiveScopes(file: File): FnDirectiveScope[];
|
|
1296
|
-
/**
|
|
1579
|
+
/**
|
|
1580
|
+
* 按绑定名找函数 scope。
|
|
1581
|
+
*
|
|
1582
|
+
* Bug 424:scope 名**不保证唯一**(同名遮蔽函数 / 嵌套同名函数)⇒ 此前
|
|
1583
|
+
* 「文档序**首个**命中」让**内层**同名函数抢走导出函数的注释块 ⇒
|
|
1584
|
+
* 导出函数继承内层的 `@nudo:throws` ⇒ **L2 门禁假绿 / 假红**。
|
|
1585
|
+
*
|
|
1586
|
+
* ⇒ 同名时取**词法最浅**的那个(`depth` 最小:顶层函数 / 类成员 = 0,
|
|
1587
|
+
* 每进入一层函数体 +1);同深度取文档序第一个。
|
|
1588
|
+
* 口径与**分析面**一致:顶层函数先登记(`generalize.ts` 的 env.fns),
|
|
1589
|
+
* 嵌套同名者被跳过 ⇒ 分析面问到的「同名函数」就是最浅的那个。
|
|
1590
|
+
*/
|
|
1297
1591
|
declare function findFnDirectiveScope(file: File, fnName: string): FnDirectiveScope | undefined;
|
|
1298
1592
|
/**
|
|
1299
1593
|
* 源文本级函数前导指令行(refine / throws / budget 的消费口)。
|
|
@@ -1303,6 +1597,11 @@ declare function fnDirectiveCommentLines(source: string, fnName: string): string
|
|
|
1303
1597
|
/**
|
|
1304
1598
|
* `@nudo:env` 载荷 → 命名 env token。只收 `\w+` 或 path-like
|
|
1305
1599
|
* (拒绝 `node";` 这类截断捕获)。
|
|
1600
|
+
*
|
|
1601
|
+
* Bug 417:此前**只按 `,` 切分** ⇒ 空格分隔列表(`node web`)被切成**一个**
|
|
1602
|
+
* token 后整条滤掉 ⇒ 零诊断地丢掉整条列表(env 未解析 ⇒ 全局 `unknown`)。
|
|
1603
|
+
* ⇒ 逗号**与**空白两种分隔符都认;尾随的注释先剥掉(行尾注释是最自然的
|
|
1604
|
+
* 写法:`/// @nudo:env node // 只需要 node`)。
|
|
1306
1605
|
*/
|
|
1307
1606
|
declare function parseEnvPayload(payload: string): string[];
|
|
1308
1607
|
type MockModuleRecord = {
|
|
@@ -1313,6 +1612,11 @@ type MockModuleRecord = {
|
|
|
1313
1612
|
/**
|
|
1314
1613
|
* `@nudo:mock-module "src" [ { a, b } ] from "path"` 载荷解析。
|
|
1315
1614
|
* 名表 `{ … }` 可选;单源文法(parser / load-deps 共用)。
|
|
1615
|
+
*
|
|
1616
|
+
* Bug 415:两条正则原**硬编码双引号** ⇒ 单引号载荷(`'axios' from './m.js'`)
|
|
1617
|
+
* 两条都不匹配 ⇒ 返回 `undefined` ⇒ 上游既不落诊断也不落记录 ⇒ 指令
|
|
1618
|
+
* **静默蒸发**(mock 不生效、门禁照常绿)。⇒ 单引号与双引号**都认**
|
|
1619
|
+
* (同一对引号必须自洽;source 与 path 的引号种类可不同)。
|
|
1316
1620
|
*/
|
|
1317
1621
|
declare function parseMockModulePayload(payload: string): MockModuleRecord | undefined;
|
|
1318
1622
|
type NudoImportRecord = {
|
|
@@ -1327,6 +1631,11 @@ type NudoImportRecord = {
|
|
|
1327
1631
|
* default 等未识别形态返回 `malformed`(由消费方发诊断)。
|
|
1328
1632
|
* import 绑定语义 local ← imported:`a as b` 两个名字都保留——只留 local
|
|
1329
1633
|
* 会让查表用错名字(`exports[b]` miss,BUG-016)。
|
|
1634
|
+
*
|
|
1635
|
+
* Bug 422:**空载荷**(「标签命中但没写载荷」)此前返回 `undefined`
|
|
1636
|
+
* (=「没有这条指令」)⇒ 畸形扫描器**永远看不到它** ⇒ 零诊断。
|
|
1637
|
+
* ⇒ 空载荷是「这条指令写坏了」⇒ 返回 `malformed`,让既有的
|
|
1638
|
+
* `nudo:contract-syntax` 通道自然接管。
|
|
1330
1639
|
*/
|
|
1331
1640
|
declare function parseNudoImportPayload(payload: string): NudoImportRecord | "malformed-default" | "malformed" | undefined;
|
|
1332
1641
|
declare function extractFileEnvNames(source: string): string[];
|
|
@@ -1336,14 +1645,22 @@ declare function extractNudoImportRecords(source: string): NudoImportRecord[];
|
|
|
1336
1645
|
/**
|
|
1337
1646
|
* 平衡括号摘取(字符串感知;`\` 不是转义——与 case 实参原样 slice 一致)。
|
|
1338
1647
|
* 返回括号内文本;无平衡括号 → null。
|
|
1648
|
+
*
|
|
1649
|
+
* ⚠ Bug 420:**配平扫描**优先按 JS 转义语义走——串里的 `\"` / `\'` 不再提前
|
|
1650
|
+
* 结束字符串 ⇒ 括号配平正确 ⇒ 含转义引号的 case 不再被**整条丢弃**,诊断也不再
|
|
1651
|
+
* 错误归因为「unclosed argument list」。
|
|
1652
|
+
* ⚠ 串**未闭合**(如 `"a\", -1`——非法 JS 串)时**回退**宽松口径(`\` 不是
|
|
1653
|
+
* 转义)——Bug 1009 钉住的实参切分口径必须保持不变(两个面看到同一个世界)。
|
|
1339
1654
|
*/
|
|
1340
1655
|
declare function extractBalancedParens(text: string, startIdx: number): string | null;
|
|
1341
1656
|
type CaseTag = {
|
|
1342
1657
|
name: string;
|
|
1343
1658
|
/** 括号内实参原文(未清洗续行 `*`) */
|
|
1344
1659
|
argsText: string;
|
|
1345
|
-
/** `=> expected` 表达式原文(同行/续行
|
|
1660
|
+
/** `=> expected` 表达式原文(同行/续行 `=>`;已剥 `!! throws` 后缀与冗余括号) */
|
|
1346
1661
|
expectedText?: string;
|
|
1662
|
+
/** 期望**写了却抽不出**的原因(消费方发 nudo:directive-syntax;Bug 918) */
|
|
1663
|
+
expectedIssue?: string;
|
|
1347
1664
|
/** 标签在 comment.value 中的下标 */
|
|
1348
1665
|
tagOffset: number;
|
|
1349
1666
|
};
|
|
@@ -1363,6 +1680,11 @@ declare function scanContractSegments(lines: string[]): string[];
|
|
|
1363
1680
|
/**
|
|
1364
1681
|
* `@nudo:throws …` / case 行 `!! throws …`。
|
|
1365
1682
|
* 返回 `*` = 申报任意;字符串 = 逗号/空白分隔的 kind 列表;undefined = 无申报。
|
|
1683
|
+
*
|
|
1684
|
+
* Bug 1033:`!! throws` 只在**指令位置**上采信(见 `scanCaseThrowsSuffixSpecs`)⇒
|
|
1685
|
+
* 散文行 / case 名内部的同形文本不再被读成**函数级**申报 ⇒ L2 门禁照常执法。
|
|
1686
|
+
*
|
|
1687
|
+
* Bug 1118:case 后缀按**实参平衡终点**定位 ⇒ 多行实参写法的申报不再丢失。
|
|
1366
1688
|
*/
|
|
1367
1689
|
declare function scanThrowsDecl(lines: string[]): string | undefined;
|
|
1368
1690
|
/** `@nudo:budget forks=… calls=… depth=…` → 声明的维度 */
|
|
@@ -1379,18 +1701,28 @@ declare function scanBudgetDecl(lines: string[]): {
|
|
|
1379
1701
|
* NudoConstraint 表达的域内。只覆盖可判定的标量子集:
|
|
1380
1702
|
*
|
|
1381
1703
|
* - prim 门(prim 缺失或不匹配字面量类型 → false)
|
|
1382
|
-
* - eq(self, lit v)
|
|
1704
|
+
* - eq(self, lit v) 字面量等值(`===` + NaN 特例;见 literalSame)
|
|
1383
1705
|
* - gt/ge/lt/le 数值常数界(self op n)
|
|
1384
1706
|
* - 字符串长度界(length(self) op n,即 min/max/length 链)
|
|
1385
1707
|
* - int(整数性)
|
|
1386
1708
|
* - members(union):任一成员满足即满足
|
|
1387
1709
|
*
|
|
1710
|
+
* **bigint**(族 11 片 S7 / Bug 915 延伸):`lit(1n)` 这类 bigint 字面量契约
|
|
1711
|
+
* 此前在本通道**判不了**(值域只放行 number / string / boolean / null /
|
|
1712
|
+
* undefined)⇒ 字段位 / 元素位对 bigint 字面量实参**零诊断**(假绿),
|
|
1713
|
+
* 而**标量实参位**(S6 修好)报违例 ⇒ 同一份契约两个位置两种裁决。
|
|
1714
|
+
* 现在字面量值域含 bigint ⇒ 域隶属通道对 bigint 与其余标量同口径。
|
|
1715
|
+
*
|
|
1388
1716
|
* 对象 / 数组 / 函数域与不可判定的 pred 形态一律 false——保守不满足,
|
|
1389
1717
|
* 对账侧宁可多报 domain-exceeds 也不放过。
|
|
1390
1718
|
*/
|
|
1391
1719
|
|
|
1392
|
-
/** 字面量 lv 是否落在约束 c 表达的域内(保守:判不了 → false)。
|
|
1393
|
-
|
|
1720
|
+
/** 字面量 lv 是否落在约束 c 表达的域内(保守:判不了 → false)。
|
|
1721
|
+
*
|
|
1722
|
+
* 值域 = `LiteralValue`(含 **bigint**;族 11 片 S7 / Bug 915 延伸)——
|
|
1723
|
+
* bigint 字面量实参此前不在值域内 ⇒ 域隶属通道对 bigint 恒不满足,
|
|
1724
|
+
* 而调用点的守卫又不放行 bigint ⇒ 字段位 / 元素位对 bigint **零诊断**。 */
|
|
1725
|
+
declare function literalMeetsConstraint(lv: LiteralValue, c: NudoConstraint, seen?: Set<object>): boolean;
|
|
1394
1726
|
|
|
1395
1727
|
/**
|
|
1396
1728
|
* Abs → NudoConstraint 投影(Phase 1,interface 分层推导的生成侧半边)。
|
|
@@ -1432,4 +1764,4 @@ declare function absToConstraint(a: Abs, budget?: ProjectionBudget): NudoConstra
|
|
|
1432
1764
|
*/
|
|
1433
1765
|
declare function joinThenProject(absList: Abs[]): NudoConstraint | undefined;
|
|
1434
1766
|
|
|
1435
|
-
export { Abs, type AbsAssignRecord, type AbsCallRecord, AbsModuleExports, AstEnv, type CaseTag, type CheckOptions, CheckReport, Confidence, EffectiveInterfaceOpts, type Environment, type ExtState, type FnAbs, type FnDirectiveScope, type FormalParam, type FormatOptions,
|
|
1767
|
+
export { Abs, type AbsAssignRecord, type AbsCallRecord, AbsModuleExports, AstEnv, type CaseTag, type CheckOptions, CheckReport, Confidence, EffectiveInterfaceOpts, type Environment, type ExtState, type FnAbs, type FnDirectiveScope, type FormalParam, type FormatOptions, HofSite, type LeqResult, LiteralValue, type MockHelper, type MockModuleRecord, NudoConstraint, type NudoImportRecord, OBJECT_PROTO_METHOD_NAMES, type ObjShape, Phi, type PolyFn, Pred, type PropFlags, RelSource, RunTranspiledOptions, Shape, type Slot, type TypeParam, absShapeKey, absToConstraint, add, applyCallbackAbs, applyCallbackValue, asAbs, assignSourceSlots, beginCollectionFork, bitandAbs, bitnotAbs, bitorAbs, bitxorAbs, buildArgsFromAssume, builtinCtorAbs, builtinCtorNameOf, callAbsMethod, canonicalArrayIndex, checkSource, clearCollectionTables, cmp, collectAbsFreeVars, collectionElementJoin, collectionExactLen, contractParamNameSet, createEnvironment, ctorArgDefinitelyInvalid, ctorNameOfRecv, definitelyNotNullishShape, div, emptyEnv, endCollectionFork, errorBrandAbs, evalArrayStatic, evalBuiltinInstanceMethod, evalBuiltinNew, evalDateCtor, evalDateMethod, evalDateStatic, evalGlobalFn, evalJsonMethod, evalMathMethod, evalNamespaceCall, evalNumberStatic, evalObjectMethod, evalObjectProtoMethod, evalRegExpCtor, evalRegExpMethod, evalStringStatic, evalSymbolCtor, evictCheckSourceMemoForPaths, evictGeneralizeMemoForPaths, extStateOf, extractBalancedParens, extractFileEnvNames, extractFn, extractMockModuleRecords, extractNudoImportRecords, falseConstraint, findFnDirectiveScope, fnDirectiveCommentLines, fnOf, formalParamDisplayNames, formalParamSignatureNames, formalParamsFromNodes, formatAbs, formatAbsMultiline, formatShape, formatShapeSlot, generalizeFromAst, getAbsProperty, getGeneralizeMemoSize, getPropFlags, getSlot, hostBuiltinCtorName, instantiateReturn, isErrorCtorName, isMapAbs, isNullProtoObj, isNullishLitAbs, isObj, isObjectProtoBrand, isRelFn, isSetAbs, isSymbolAbs, joinAbs, joinFunctions, joinObjects, joinThenProject, joinValues, leqAbs, listFnDirectiveScopes, listFunctionNames, literalMeetsConstraint, locateContractParam, looseEqAbs, makeArrayCtorAbs, makeMapAbs, makeSetAbs, makeSum, makeSymbolAbs, mapClearEntries, mapDeleteEntry, mapElementFallback, mapEntriesAbs, mapGetEntry, mapHasEntry, mapSetEntry, mapSizeAbs, mapValuesAbs, markExtState, markNullProtoObj, matchRelIdentLit, mergeCollectionArms, migrateInvariants, migrateNullProto, mock, mod, mul, negAbs, notAbs, noteCollectionWrite, objOf, objectProtoBrand, objectProtoMethodAbs, parseEnvPayload, parseMockModulePayload, parseNudoImportPayload, parseSource, popCollectionArm, powAbs, projectFlatMapResult, propertyKeyOf, protoBrandAbs, protoOfRecv, pushCollectionArm, refineAbsForRelTrue, regexBrandAbsFrom, requiredFnArity, resetCheckSourceMemo, resetGeneralizeMemo, scanBudgetDecl, scanCaseArgSpans, scanCaseTags, scanContractSegments, scanThrowsDecl, setAddEntry, setApplyCallbackHost, setClearEntries, setDeleteEntry, setElementsAbs, setHasEntry, setPropFlags, setSizeAbs, shlAbs, shrAbs, snapshotAbs, spread, spy, strictEqAbs, stringOfSymbol, stripTypes, stub, sub, substAbs, substPredAbs, symbolDescriptionAbs, symbolIdOf, toNumberAbs, trueConstraint, tryMakeRegexAbs, typeofAbs, undefAbs, ushrAbs, withVar };
|