@nudojs/core 1.15.2 → 1.16.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/exec.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as Abs, M as MayThrowEffect, b as Phi } from './run-DfloWX6i.js';
2
- export { W as $assignRecord, X as $call, Y as $callNamed, bI as $nodoPos, Z as $recordBinding, a5 as EvalAbsAssignRecord, a6 as EvalCallRecord, a7 as EvalFallback, g as EvalFallbackStats, a8 as EvalPosRecord, ab as MAX_EVAL_CALL_DEPTH, ac as MAX_EVAL_TOTAL_CALLS, ad as RUNTIME_IMPORT_RE, V as RunTranspiledOptions, af as TranspiledCallResult, at as bindingsOf, aw as callTranspiledExport, ax as callTranspiledExportApply, ay as callTranspiledExportFull, l as clearPureCallMemo, m as clearPureMemo, n as enterEvalCallBudgetSession, aD as evalExprAbs, p as exitEvalCallBudgetSession, v as getEvalCallBudgetState, aG as getEvalCallCollector, w as getEvalFallbackStats, bJ as getPosCollector, aO as isAbsVal, aQ as isCjsMainRun, b5 as noteEvalCallRecord, b6 as noteEvalFallback, bn as resetEvalCallBudget, H as resetEvalFallbackStats, bK as routeApplyThrows, bo as runTranspiled, bp as runTranspiledOptionsMemoKey, bq as setEvalAssignCollector, br as setEvalBindingSink, bs as setEvalCallCollector, bt as setEvalFallbackCollector, bv as setPosCollector, bF as tryRunTranspiled, O as withEvalBudgetOverride } from './run-DfloWX6i.js';
1
+ import { A as Abs, M as MayThrowEffect, b as Phi } from './run-T9HWTziZ.js';
2
+ export { W as $assignRecord, X as $call, Y as $callNamed, bI as $nodoPos, Z as $recordBinding, a5 as EvalAbsAssignRecord, a6 as EvalCallRecord, a7 as EvalFallback, g as EvalFallbackStats, a8 as EvalPosRecord, ab as MAX_EVAL_CALL_DEPTH, ac as MAX_EVAL_TOTAL_CALLS, ad as RUNTIME_IMPORT_RE, R as RunTranspiledOptions, af as TranspiledCallResult, at as bindingsOf, aw as callTranspiledExport, ax as callTranspiledExportApply, ay as callTranspiledExportFull, l as clearPureCallMemo, m as clearPureMemo, n as enterEvalCallBudgetSession, aD as evalExprAbs, p as exitEvalCallBudgetSession, v as getEvalCallBudgetState, aG as getEvalCallCollector, w as getEvalFallbackStats, bJ as getPosCollector, aO as isAbsVal, aQ as isCjsMainRun, b5 as noteEvalCallRecord, b6 as noteEvalFallback, bn as resetEvalCallBudget, H as resetEvalFallbackStats, bK as routeApplyThrows, bo as runTranspiled, bp as runTranspiledOptionsMemoKey, bq as setEvalAssignCollector, br as setEvalBindingSink, bs as setEvalCallCollector, bt as setEvalFallbackCollector, bv as setPosCollector, bF as tryRunTranspiled, O as withEvalBudgetOverride } from './run-T9HWTziZ.js';
3
3
  import { Node, Expression, File } from '@babel/types';
4
4
 
5
5
  /**
@@ -23,6 +23,19 @@ declare function isNudoThrow(e: unknown): e is NudoThrow;
23
23
  /**
24
24
  * 求值引擎运行时共享状态:phi、就地写、字面量 Abs、真值、循环信号。
25
25
  * 叶子模块——不依赖 runtime 其它文件(tuple/obj 字面量就地构造,避免 state↔containers 环)。
26
+ *
27
+ * Invariants:
28
+ * - Bug 213:宿主 / 命名空间对象(Math / JSON / Reflect)的自有属性投影按
29
+ * **getOwnPropertyNames**(全部自有字符串键)而非 Object.entries(只取可
30
+ * 枚举键)——原生这些对象的自有属性几乎全不可枚举,按可枚举投影会把整个
31
+ * 自有面丢掉(gOPN / ownKeys / hasOwn / gOPD 全折 0);逐键记 enumerable /
32
+ * writable / configurable 标志,不可枚举键仍不进枚举面。
33
+ * - Bug 210:enforceProxyGetInvariant 是 Proxy [[Get]] 规范不变量的单一实现
34
+ * (靶上自有属性不可配置且不可写时,get 陷阱须返回其实际值);
35
+ * proxyTargetInnerObj 归一化「靶 → 内层 obj Abs」(不变性侧表与槽表都挂
36
+ * 在内层 obj 上——brand 包装的靶走内层)。
37
+ * [[OwnPropertyKeys]] 不变量(重复名 / 漏键 / 多余键)在
38
+ * builtins/object/descriptor.ts(enforceProxyOwnKeysInvariant)。
26
39
  */
27
40
 
28
41
  /** 调用方已直接改 shape 时的 term/pred 清理 */
@@ -39,6 +52,8 @@ declare function withAssumePremises<T>(p: Phi, body: () => T): T;
39
52
  * extractParamNames 回退口径一致);带真实参数名走 $fnVal(transpile 侧)。
40
53
  */
41
54
  declare function asAbsVal(v: unknown): Abs;
55
+ /** transpile 生成代码用:给宿主函数打种类戳(Bug 325) */
56
+ declare function $fnKindStamp(fn: unknown, kind: string): void;
42
57
  /** transpile 侧收形入口(instanceof RHS 值等):host 裸值 / Abs → Abs。
43
58
  * `$` 前缀是运行时绑定表(runtimeArgNames)的注入约定。 */
44
59
  declare function $absVal(v: unknown): Abs;
@@ -70,6 +85,8 @@ declare function $fnVal(params: string[], impl: (...args: Abs[]) => Abs, opts?:
70
85
  effectFree?: boolean;
71
86
  closed?: boolean;
72
87
  kind?: string;
88
+ fnKind?: "function" | "async" | "generator" | "async-generator";
89
+ optionalParams?: boolean[];
73
90
  }): Abs;
74
91
  /**
75
92
  * 宿主 this → Abs:函数体 prologue 用它承接 call/apply/bind 传入的 thisArg。
@@ -188,6 +205,17 @@ declare function $join(a: Abs, b: Abs): Abs;
188
205
 
189
206
  /**
190
207
  * 访问器(get/set)侧表、in / instanceof / delete 路由。
208
+ *
209
+ * Bug 149:符号键(Symbol.iterator 等)按**宿主身份**反查 "@@X" 内部槽键
210
+ * 寻址(与读写面同口径),Proxy has 陷阱收到**真 symbol**(规范
211
+ * PropertyKey)——不再在「键不可判」处提前 return(陷阱此前完全不派发)。
212
+ * Bug 230:delete 运算符路径($delRes)的 Proxy [[Delete]] 规范不变量——
213
+ * deleteProperty 陷阱返 true 时,若靶上该键是不可配置自有属性 ⇒ 原生定抛
214
+ * TypeError(此前直接返 true,假绿;Reflect 臂已由 S9 接线)。
215
+ * Bug 194:`delete X.prototype.m` —— 类方法在方法注册表(spec.methods)里,
216
+ * 原型对象上无该方法的槽 ⇒ 只删槽不留痕(读/调用/in 三面继续命中)。
217
+ * $del 在 `.prototype` brand 臂按 owner 名通知注册表侧移除(S8 的
218
+ * deleteProtoMethod 钩子);delete 返回值恒 true(原生同)。
191
219
  */
192
220
 
193
221
  /** 计算键访问器注册(`{ get [expr]() {} }`):键为 Abs,ToPropertyKey 后注册。
@@ -210,11 +238,18 @@ declare function $instanceof(left: Abs, rightName: string, rightVal?: Abs): Abs;
210
238
  /** instanceof 右操作数非标识符(表达式/成员路径):RHS 值传入时先做原生
211
239
  * 非对象校验(definite / may TypeError);构造器值未知 → 抽象 boolean */
212
240
  declare function $instanceofNonIdent(left: Abs, right?: Abs): Abs;
213
- /** ClassExpression 值:构造器函数形状,不得折成精确 undefined */
214
- declare function $classExpr(): Abs;
241
+ /**
242
+ * ClassExpression 值:构造器函数形状,不得折成精确 undefined。
243
+ *
244
+ * Bug 133:name —— **NamedEvaluation 名**(`const K = class {}` → "K")。
245
+ * 空类体走本快路径(fn 形状),类名落在 fn 形状的 name 位($get(fn,"name")
246
+ * 读 shape.name)——无名类不传(原生名为空串)。
247
+ */
248
+ declare function $classExpr(name?: string): Abs;
215
249
  /**
216
250
  * `delete obj[key]` 的结果判定(只读,不写回)。
217
251
  * frozen/sealed 或 configurable:false 键 → false;preventExtensions 可删;
252
+ * 数组 length 恒不可配置 → strict 定抛 TypeError(Bug 230);
218
253
  * closed 目标恒 true(其余 non-configurable 形态不建模);
219
254
  * nullish 接收者原生 definite TypeError(ToObject(null) 抛)→ hard NudoThrow;
220
255
  * 非 nullish prim 接收者原生不抛(装箱临时对象上 delete 恒 true,strict 亦然)
@@ -224,7 +259,8 @@ declare function $delRes(o: Abs, _key: Abs): Abs;
224
259
  /**
225
260
  * `delete obj[key]` 的写入(不可变更新):返回删键后的新容器。
226
261
  * 闭对象删自有槽;tuple 规范下标置 undefined(对齐原生空洞读值);
227
- * 抽象 arr 元素并入 undefined;无法表达的形态原样返回。
262
+ * 抽象 arr 元素并入 undefined;数组 length 不可配置 → strict 定抛
263
+ * TypeError(Bug 230);无法表达的形态原样返回。
228
264
  */
229
265
  declare function $del(o: Abs, key: Abs): Abs;
230
266
 
@@ -233,6 +269,14 @@ declare function $del(o: Abs, key: Abs): Abs;
233
269
  * 下沉原因:objects.ts 的 joinObjects 需感知访问器(join 不迁移侧表会丢
234
270
  * getter 读域),而 members.ts 依赖 objects.ts;表放无运行时依赖的叶子上
235
271
  * 才能被两层共用而不成环。in / instanceof / delete 路由仍在 members.ts。
272
+ *
273
+ * 不变量:
274
+ * - 访问器**不住在 shape 槽里**:transpile 只落一个 `$lit(void 0)` 占位槽
275
+ * (保键存在性:'x' in o / keys / assign 拷贝目标),真 getter 住本侧表;
276
+ * - 读通道($get/$set)先查侧表再回落槽值 ⇒ `o.ab` 读得对;
277
+ * - **投影通道**(formatShape / denoteGuard / absToConstraint / 契约证明)
278
+ * 必须先经 accessorReadDomain 取读域,否则把占位槽渲染成 exact
279
+ * `undefined`——一个自信的错值(比真值更窄且自相矛盾,Bug 191)。
236
280
  */
237
281
 
238
282
  /** 注册对象字面量访问器(transpile 调用;返回原 obj 以便链式包裹) */
@@ -268,6 +312,9 @@ declare function $for(init: Abs, test: (s: Abs) => Abs, step: (s: Abs) => Abs, b
268
312
  unpack?: (s: Abs) => void;
269
313
  /** 标签循环(`outer: for …`):仅吸收同标签 break/continue 信号 */
270
314
  label?: string;
315
+ /** 循环变量的最新写(Bug 228):continue 臂取「体退出瞬间的循环变量值」
316
+ * ——转译侧在体的 finally 里写回共享槽;缺省(未插桩)时以 state 近似。 */
317
+ loopVar?: () => Abs;
271
318
  }): Abs;
272
319
  /**
273
320
  * 有界 while:state 线程穿 test/step(与 $for 同折叠语义)。
@@ -292,6 +339,13 @@ declare function $whileSeq(test: () => Abs, body: () => void, maxIters?: number,
292
339
  * 抽象路径与 $fork 同构:集合 side-table 按臂 overlay,共享 body 只跑一次;
293
340
  * 臂内 NudoReturn/NudoThrow 不冒泡污染兄弟臂。
294
341
  * **无 default 时必须隐式 fall-through 臂(undef)**,否则无匹配路径被丢掉(P0-2)。
342
+ *
343
+ * Bug 241:**字面量判别式 + 非字面量 case 测试**(`switch (true) { case x > 0: … }`)
344
+ * ——原生里 case 测试是运行时求值的表达式,命中与否取决于测试值;此前字面量
345
+ * 判别式路径只接受「case 测试也是字面量」的臂,其余臂被**整条丢弃**(永不
346
+ * 命中)⇒ 臂内返回值从返回域/签名里消失 ⇒ 契约真实违约被漏报(L1 门禁假绿)。
347
+ * 修法:遇到非字面量 case 测试 ⇒ **分叉**(命中该臂 / 不命中继续后续臂与
348
+ * default),两路结果并入返回域(switchForked)。
295
349
  */
296
350
  declare function $switch(disc: Abs, cases: Array<{
297
351
  test: Abs;
@@ -305,7 +359,15 @@ declare function $throw(v: Abs): never;
305
359
  * 不得污染 join 后的 continue 绑定。
306
360
  */
307
361
  declare function $isForkExit(e: unknown): boolean;
308
- /** catch 参数:从 NudoThrow 取出 Abs;宿主 Error 补 name/message;否则 unknown */
362
+ /**
363
+ * catch 参数:从 NudoThrow 取出 Abs;宿主 Error 补 name/message;否则 unknown。
364
+ *
365
+ * Bug 211:**控制流信号(break / continue)不是异常**——原生里 `break` 是
366
+ * 控制流完成值,根本到不了 catch 处理器(catch 体不跑、循环照常退出)。
367
+ * 引擎的循环信号是 Error 子类 ⇒ 会被 catch 接住;此前 catch 体把信号「吃掉」
368
+ * (副作用照跑、循环还不退出)。修法:控制流信号在此**重抛** ⇒ catch 体不执行、
369
+ * 信号透传到循环捕获点(catch 体只吞真异常)。
370
+ */
309
371
  declare function $catchVal(e: unknown): Abs;
310
372
 
311
373
  /**
@@ -317,6 +379,8 @@ declare function $catchVal(e: unknown): Abs;
317
379
  * 迁移,副本丢失侧表 = 臂内写不再硬抛 / 延迟异常静默丢弃。
318
380
  * - $spread 原生语义会**调用**源对象 getter 并把结果拷为数据槽——必须
319
381
  * 用 getter 求值后的副本(accessorTable 求值,抛/失败折 unknown)。
382
+ * - $objRest 同理:原生 CopyDataProperties 对保留键发 Get ⇒ getter 必须
383
+ * 被调用(副作用发生),rest 槽落 getter 的**返回值**(非占位 undefined)。
320
384
  */
321
385
 
322
386
  /**
@@ -338,9 +402,10 @@ declare function $setProto(o: Abs, proto: Abs): Abs;
338
402
  declare function $spread(a: Abs, b: Abs): Abs;
339
403
  /**
340
404
  * 解构 rest:`const { a, ...rest } = o` → rest = o 去掉 named keys。
405
+ * 排除集可含**动态计算键**(Abs)——原生按求值后的键排除(Bug 160)。
341
406
  * closed obj:剩余槽 closed;open / optional 键:rest 仍 open(可能有未知键)。
342
407
  */
343
- declare function $objRest(o: Abs, keys: string[]): Abs;
408
+ declare function $objRest(o: Abs, keys: Array<string | Abs>): Abs;
344
409
 
345
410
  /**
346
411
  * 元组/数组构造与宽化。
@@ -392,6 +457,9 @@ declare function $restBind(list: ArrayLike<unknown>, namedCount: number): Abs;
392
457
  * 抽象 → may(空接收者同样先校验);values 实参不校验(原生存储不转换)。
393
458
  * - mutator 降 arr(splice 等)的元素域 = 全部观测元素 join——不并入
394
459
  * OOB undefined(issue #156 元素域约定)。
460
+ * - 完整性门(Bug 223):frozen 任何 mutator 抛;sealed 的**结构性扩展**
461
+ * (push/unshift/splice)与**删除既有自有属性**(pop/shift 命中自有元素)
462
+ * 抛 TypeError;空数组 / 空洞位 / preventExtensions(nonext)不抛。
395
463
  */
396
464
 
397
465
  declare function isArrMutator(name: string): boolean;
@@ -421,6 +489,10 @@ declare function $arrMutContainer(arr: Abs, method: string, args: Abs[]): Abs;
421
489
  * (issue #175:否则 xs[0].length - xs[1].length 假折 0)。
422
490
  * - abstractLen memo 只对**绑定接收者**合法(跨读同 term sound);
423
491
  * lenVarSeq 单调递增,len#N term 全局唯一。
492
+ * - Bug 209:Proxy **set 陷阱**返回值按规范 ToBoolean 判定——falsy(0 / "" /
493
+ * null / undefined / false)→ strict TypeError(只认字面量 false 会漏)。
494
+ * - Bug 197:下标写查 defineProperty 的 writable:false → strict TypeError
495
+ * (此前下标臂只查 frozen / sealed,flags 面没查 → 写穿无声)。
424
496
  */
425
497
 
426
498
  /** 下标读 a[i];规范数组下标走精确投影,确定非下标键 → undefined,否则并所有元素;string[i] → 单字符 */
@@ -444,20 +516,64 @@ declare function $len(a: Abs, opts?: {
444
516
  * 内层空 obj,原型链 @@iterator 不在内层建模)。
445
517
  * - 生成器/模板标签/matchAll 迭代物挂对象侧表:迭代 = 消费(从当前位
446
518
  * 取剩余),体内延迟异常在消费点重放(不得静默截断成前缀,Bug 34)。
519
+ * - async generator(仅 @@asyncIterator 槽的**生成器对象**,Bug 141):
520
+ * for-await 的元素域走**元素侧表**(与同步 generator 同口径:元素取
521
+ * 侧表剩余条目,长度亦由侧表给出)——不得落 asyncOnly 的 unknown 快
522
+ * 路径(元素域精度回退);非生成器的仅异步可迭代对象元素域不可静态刻
523
+ * 画 → 仍折 unknown。
447
524
  * - unbounded(长度未知)单代表迭代只跑一次:0 次/出口臂由 fork-arm +
448
525
  * snapExit join 承接;break/continue 打断代表体 → widen.markInterrupted
449
526
  * (完整迭代效应不可观测,累加器域整体宽化)。
527
+ * - Bug 195:标签模板对象是**冻结的数组 exotic**(原生 GetTemplateObject →
528
+ * CreateArrayFromList + SetIntegrityLevel(frozen))⇒ 元槽(length / raw /
529
+ * @@iterator)**非枚举**、对象**冻结**(extState)、JSON 走**数组序列化面**
530
+ * (数组视图标注)。未冻结的普通 obj 不得被误标。
531
+ * - Bug 198:Map/Set 的条目遍历(forEach / for-of)必须是**接收者的 live
532
+ * 视图**——回调里的增删删改对迭代可见(live 视图按访问序取,条目身份去重)。
533
+ * - Bug 198(S20):live 集合 / 数组迭代器**不登记静态元素侧表**(静态表是
534
+ * 创建期拷贝 ⇒ 元素面与长度冻结在创建时刻)⇒ 迭代物判定($arrRest 的
535
+ * 「侧表迭代物」门、$yieldStarElems 的长度可知性)必须**同口径**认
536
+ * **消费视图**(registerGenDrain)——只查静态侧表会把 live 迭代物误判成
537
+ * 「非迭代物」(rest 解构退 unknown)。
538
+ * - Bug 199:非正常出口(break / return / throw / label break)与**解构模式
539
+ * 填满而迭代器未耗尽**必须 IteratorClose(调用户迭代器的 return());continue
540
+ * 与自然耗尽**不**调;无 return 槽**不**凭空抛(抽象面不判定)。
541
+ * - Bug 200:for..in 遍历 brand 实例须**沿原型链**枚举可枚举键(原型上的
542
+ * class 方法非可枚举 ⇒ 不出现)。
543
+ * - Bug 215:for-of 的**具体出口**(无快照 join)也须实施 @nudo:invariant 公理
544
+ * (无公理时不取绑定包——零行为变化)。
450
545
  */
451
546
 
452
547
  /** 数组 rest:`const [a, ...rest] = arr` → rest = 从 start 起的尾段 */
453
548
  declare function $arrRest(a: Abs, start: number): Abs;
454
549
  /** 数组连接 [...a, ...b] / [...a, x];结果超 cap 时与字面量同策略降 arr */
455
550
  declare function $concat(a: Abs, b: Abs): Abs;
456
- /** 数组解构模式接收者守卫:原生数组解构 = GetIterator + IteratorNext,
457
- * 非可迭代接收者抛 TypeError。emitDestructure 的 ArrayPattern 分支在逐项
458
- * $idx / $arrRest 投影前调用;值域投影不变(字符串/元组等可迭代接收者
459
- * 不受影响)。 */
460
- declare function $iterCheck(a: unknown): void;
551
+ /**
552
+ * 用户 iterable 的**迭代序**元素读取器(`$iterCheck` 返回值):
553
+ * - `get(i)`:第 i 个元素(迭代序);越界 = 迭代已 done → exact undefined;
554
+ * 列表被截断(truncated)→ unknown(sound)。
555
+ * - `rest(i)`:从第 i 项起的剩余元素(原生 rest 语义:迭代到 done 为止);
556
+ * 截断 → unknown(剩余长度不可知)。
557
+ */
558
+ interface UserIterReader {
559
+ get(i: number): Abs;
560
+ rest(i: number): Abs;
561
+ }
562
+ /**
563
+ * 数组解构模式接收者守卫 + **用户 iterable 迭代序元素读取器**。
564
+ *
565
+ * 两件事(同一调用,避免生成码再判一次接收者形态):
566
+ * ①守卫:原生数组解构 = GetIterator + IteratorNext,非可迭代接收者抛
567
+ * TypeError(definite);抽象接收者记 may-throw。
568
+ * ②返回用户 iterable(对象带自有 `@@iterator` 槽、引擎无其元素模型)的
569
+ * 迭代序元素读取器;**非**用户 iterable → null ⇒ 调用方走既有 `$idx` /
570
+ * `$arrRest` 快速路径(tuple / 数组 / 字符串 / Set / Map / 生成器 /
571
+ * `$tpl` / 数组迭代器…逐字不变)。
572
+ *
573
+ * `maxElements`:本次最多取几个元素(原生按需取:模式有 n 个位置就取 n 个,
574
+ * 空位也消耗一个);缺省 / 负数 = 取到 done(受 USER_ITER_MAX_STEPS 上界约束)。
575
+ */
576
+ declare function $iterCheck(a: unknown, maxElements?: number): UserIterReader | null;
461
577
  /** 元素列表(tuple 展开;arr 抽象;C1 Set/Map 逐条目;matchAll 迭代器逐匹配项;
462
578
  * 字符串按 code points)。Map 迭代语义是 entry `[key, value]` 元组,不是裸 value。
463
579
  * 消费前先过可迭代性守卫(Bug 6):prim 字面量接收者 → 原生 definite
@@ -469,18 +585,28 @@ declare function $elems(a: Abs): Abs[];
469
585
  * 为 cooked 字符串(无效转义序列时 cooked 是 undefined,原生实测)、
470
586
  * length 精确、.raw 为 raw 字符串数组;@@iterator 槽给函数形状
471
587
  * (`[...s]` / `for..of` / `Symbol.iterator in s` 均按可迭代面判定,
472
- * 不得把冻结数组误判 definite 不可迭代)。 */
473
- declare function $tpl(cooked: Array<string | undefined>, raw: string[]): Abs;
474
- /**
475
- * for-of:对 iterable 每个元素跑 body;有界展开。
476
- * body(item, i) 可返回 void;状态由外部 JS 变量承接。
477
- * - 具体空 tuple:体 0 次(不得用 `length || maxIters` 展开成 maxIters)
478
- * - 抽象 arr / 未知长度:0..maxIters 出口与 pack 状态 join
479
- */
480
- /**
481
- * for-in 键序列:原生顺序为整数键升序 → 其余键按插入序;
482
- * 数组 hole 槽不出键(读值为 undefined 但不可枚举)。仅自有可枚举键。
588
+ * 不得把冻结数组误判 definite 不可迭代)。
589
+ *
590
+ * Bug 195:原生 GetTemplateObject = `CreateArrayFromList` + `SetIntegrityLevel(frozen)`
591
+ * ⇒ 模板对象是**冻结的数组 exotic**:
592
+ * - `length` / `raw` / `@@iterator` 是**非枚举**自有属性(原生三者全非枚举;
593
+ * `Object.keys(s)` 只有下标 "0".."n-1")——此前平铺为可枚举槽 ⇒ Object.keys
594
+ * 折出 "0,1,length,raw,@@iterator"(错值)。
595
+ * - `Object.isFrozen(s)` / `Object.isFrozen(s.raw)` 均为 true(原生冻结)——
596
+ * 此前 false。冻结走 extState 侧表(`Object.isFrozen` 的判定源)。
597
+ * - `JSON.stringify(s)` 走**数组序列化**(原生 `["a","b"]`)——此前走 obj 面
598
+ * 折 `{"0":"a",...}`。数组视图标注(markMatchArrayView)复用 RegExp exec
599
+ * 结果同款机制(json.ts 消费,不改 json.ts)。
600
+ *
601
+ * **未建模(越界,需 member.ts / builtins/array.ts)**:
602
+ * - `Array.isArray(s)` 原生 **true**(模板对象是数组 exotic)——引擎 isArray
603
+ * 只认 arr/tuple 形状 ⇒ 仍折 false(需 builtins/array.ts 查模板对象标注)。
604
+ * - 数组原型方法(`s.join` / `s.map` / `s.slice` / `s.indexOf` / `s.concat`)
605
+ * 原生可调(模板对象继承 Array.prototype)——引擎 obj 接收者的数组方法
606
+ * 派发面只认 tuple/arr 形状 ⇒ 此前折**确定抛 TypeError**(假抛)。
607
+ * 需 member.ts 的 $get 数组方法臂认模板对象(按元素侧表投影)。
483
608
  */
609
+ declare function $tpl(cooked: Array<string | undefined>, raw: string[]): Abs;
484
610
  declare function $forInKeys(o: Abs): Abs;
485
611
  declare function $forOf(iterable: Abs, body: (item: Abs, index: Abs) => void, maxIters?: number, opts?: {
486
612
  pack?: () => Abs;
@@ -489,7 +615,9 @@ declare function $forOf(iterable: Abs, body: (item: Abs, index: Abs) => void, ma
489
615
  label?: string;
490
616
  /** for await:接收者按 GetIterator(hint=async) 校验(@@asyncIterator 槽
491
617
  * 即全量);仅异步可迭代(无 @@iterator 槽)的接收者不折同步槽位投影,
492
- * 元素取抽象 unknown(原生由 next() 链驱动)。 */
618
+ * 元素取抽象 unknown(原生由 next() 链驱动)——**async generator 例外**
619
+ * (Bug 141):它是生成器对象,元素域走元素侧表(与同步 generator
620
+ * 同口径)。 */
493
621
  forAwait?: boolean;
494
622
  /** for-in(Bug 98):接收者重查 thunk——快照键进体前重查在场,体内
495
623
  * delete 的未访问键跳过该迭代(与原生 EnumerateObjectProperties 的
@@ -501,6 +629,11 @@ declare function $forOf(iterable: Abs, body: (item: Abs, index: Abs) => void, ma
501
629
  * Map/Set forEach:条目表逐条调用回调(value, key, recv)。
502
630
  * 回调是 求值引擎 JS 函数(transpile 内联箭头)直接调用;Abs fn 走 $call。
503
631
  * 回调返回值丢弃;forEach 表达式值恒 undefined。
632
+ *
633
+ * Bug 198:**live 视图**——原生 forEach 持条目指针:迭代期间新增的条目被
634
+ * 访问、删除的条目被跳过(`m.forEach(v => { out.push(k); m.set("b",2) })`
635
+ * 原生 "a,b",引擎快照口径只有 "a")。表不干净(shadow / maybeAbsent)⇒
636
+ * 无 live 视图 ⇒ 沿用快照口径。
504
637
  */
505
638
  declare function $collectionForEach(recv: Abs, cb: unknown): Abs | undefined;
506
639
 
@@ -517,6 +650,51 @@ declare function $collectionForEach(recv: Abs, cb: unknown): Abs | undefined;
517
650
  * - 闭 shape 字面量 key miss → 精确 undefined(键确定不存在);open
518
651
  * shape / 抽象键 → 并 unknown(键可能存在);已知原型访问器名槽面
519
652
  * 未建模 → 诚实 unknown(不得 wrong-exact undefined)。
653
+ * - Bug 149:符号投影键("[Symbol.X]" → "@@X")在 **Proxy 陷阱边界**还原成
654
+ * 真 symbol(规范 PropertyKey);字面量串键 "@@X" 不带标记,仍是字符串键。
655
+ * - Bug 218:prim(number/boolean/bigint/symbol)读**确定不存在**的成员 →
656
+ * undefined 字面量(原生语义),不是 unknown——unknown 接收者不记
657
+ * may-throw,会让后续读该值的 TypeError 丢失(L2 门禁假绿)。
658
+ * - Bug 219:symbol prim 的 toString/toLocaleString/valueOf 走
659
+ * **Symbol.prototype 自己的面**(toString/valueOf 带 brand check——
660
+ * 借用调用非 symbol 接收者定抛 TypeError),不落 Object.prototype 泛型版。
661
+ * - Bug 206/225:类值写面的两个原生「不可写」——`A.prototype = v` 与
662
+ * getter-only 静态访问器的写,都定抛 strict TypeError(例外:引擎内部
663
+ * defineProperty 对原型的就地改写回装)。
664
+ * - Bug 234:类值的 `constructor` = 内建 Function(原生继承自
665
+ * Function.prototype),不是「以类名命名的内建构造器」。
666
+ * - Bug 235:Proxy 无 get 陷阱时转发 `target.[[Get]](key, Receiver)`——
667
+ * Receiver 必须是 proxy 自己(靶上 getter 的 this = receiver,不是靶)。
668
+ * - Bug 210:Proxy **get 陷阱**返回值过 [[Get]] 规范不变量(state.ts 的
669
+ * enforceProxyGetInvariant)——靶上自有属性不可配置且不可写时,陷阱值
670
+ * 须 SameValue 靶值,否则原生定抛 TypeError(此前直接返陷阱值,假绿)。
671
+ * - Bug 209:Proxy **set 陷阱**返回值按规范 ToBoolean 判定——falsy(0 / "" /
672
+ * null / undefined / false)→ strict TypeError(只认字面量 false 会漏)。
673
+ * - Bug 197:[[Set]] 写门——receiver **无自有该键**时沿 [[Prototype]] 链
674
+ * 上溯(OrdinarySet):访问器(无 setter)→ strict TypeError;带 setter
675
+ * → 派发 setter;数据属性 writable:false / frozen 原型 → strict
676
+ * TypeError;链上无人持该键 → receiver 建自有属性。fn 臂 / 静态类值臂 /
677
+ * 数组下标臂另查 defineProperty 的 writable:false(见 proto-set.ts)。
678
+ * **类实例面**同走该门(原型 = `A.prototype`,proto-set.ts 经
679
+ * protoOfRecv 解析类注册表)——此前类实例未登记 protoTable ⇒ 门恒 allow
680
+ * ⇒ 原型上动态装的只读属性 / getter-only 被静默写穿。
681
+ * - Bug 223/231:数组 length 写门——域判定走 ToNumber(具体非数值
682
+ * undefined / {} / "abc" 定抛 RangeError,Symbol 抛 TypeError);sealed
683
+ * 数组 length **截断**写要删不可配置元素 → strict TypeError(增长合法;
684
+ * preventExtensions 不冻结元素 → 截断不抛)。见 array-length.ts。
685
+ * - Bug 198(S20):内建 brand 实例上的 `@@iterator` 读值 = **原型上同一个
686
+ * 函数对象**(原生 m[Symbol.iterator] === Map.prototype[Symbol.iterator])
687
+ * ⇒ 走符号成员表(builtinSymbolMemberAbs),不得给 no-op fn——no-op fn 被
688
+ * 调用折 <abs:never>(自信的错值:原生返回集合迭代器)。Map/Set 的该成员
689
+ * 产出 **live 视图**集合迭代器(collectionIteratorFor),投影口径同原生:
690
+ * Map → [k,v] 元组(entries),Set → 元素本身(values,非 [el,el])。
691
+ * - Bug 291:fn 臂的**不变性写门**与 obj 臂同款——frozen 全写 strict
692
+ * TypeError;sealed/nonext 新键 TypeError(函数亦是不可扩展对象)。
693
+ * - Bug 315:本模块向 builtins/object-proto.ts 注册**接收者 toString 解析
694
+ * 钩子**(Object.prototype.toLocaleString 委派 this.toString())——注册式
695
+ * 注入断开 builtins↔exec 的 import 环(同 protoMethodDispatch 口径)。
696
+ * - Bug 325:fn impl 的 kind 值域含 "async-generator"(与 "generator" 同有
697
+ * 原生 prototype)——prototype 面读该戳。
520
698
  */
521
699
 
522
700
  declare function namespaceNameOf(v: unknown): string | undefined;
@@ -524,8 +702,17 @@ declare function namespaceNameOf(v: unknown): string | undefined;
524
702
  declare function $regex(pattern: string, flags?: string): Abs;
525
703
  /** 成员读:obj.slots[key];缺失 → undefined 字面量;brand 解包内层 */
526
704
  declare function $get(o: Abs, key: string, opts?: {
527
- silent?: boolean;
528
- }): Abs;
705
+ /** 调用方已负责诊断(如 $invoke) */ silent?: boolean;
706
+ /** Bug 149:键来自符号投影("[Symbol.X]" → "@@X")——陷阱边界还原真 symbol */
707
+ symbolKey?: boolean;
708
+ },
709
+ /**
710
+ * Bug 235:[[Get]] 的 **receiver**(规范 Proxy.[[Get]](P, key, Receiver)
711
+ * 无 get 陷阱时转发 `target.[[Get]](key, Receiver)`)。缺省 = 接收者自身。
712
+ * 只作用于本次读取的访问器 `this` 绑定——不向下递归传递(内层读取的
713
+ * receiver 仍是它自己的接收者)。
714
+ */
715
+ receiver?: Abs): Abs;
529
716
  /** 成员写:返回新 obj/brand(不可变更新);frozen/sealed/只读目标按 sloppy 静默失败。
530
717
  * opts.internal(Bug 84):私有字段落地——槽打 Slot.internal 标记;后续覆写
531
718
  * 保留既有标记(this.#x = v 不丢失 internal)。
@@ -539,6 +726,22 @@ declare function $set(o: Abs, key: string, value: Abs, opts?: {
539
726
 
540
727
  /**
541
728
  * async / await / generator / ??($nullishTest / $removeNullish)。
729
+ *
730
+ * 不变量(本文件):
731
+ * - `$await` 的取值面 = 原生的 adopt 口径:promise 走 eff("promise") 通道
732
+ * (**双臂** promise 的 rejected 臂不得丢——记入 throw 通道供体内
733
+ * try/catch 吸收,未被吸收者并入 promise 的 rejected 通道);**thenable**
734
+ * (闭对象 + 自有 then 槽)走 PromiseResolve 式采纳(取 then(res, rej)
735
+ * 的 settle 值,不是 thenable 本身)。any/unknown/fn/开对象的采纳面
736
+ * 不可判 → 保持原值(不猜、不用 unknown 掩盖)。
737
+ * - Bug 1052:thenable 采纳的**判定与调用**与 promise 构造面(`Promise.resolve`
738
+ * / `new Promise(resolve => resolve(thenable))`)**同一套机制**
739
+ * (`builtins/promise.ts` 的 `thenableAdoption`)——本文件只做 await 面的
740
+ * 语义映射(reject → throw;未 settle → 悬挂)。
741
+ * - 生成器对象是**内部槽对象**:协议方法与 yield 元素的槽标 internal
742
+ * (枚举面 / 自有面不可见;$get / $in 照常直读直查)。
743
+ * - `yield*` 委托的 `.return(v)` 必须**转发**给委托迭代器(委托的清理
744
+ * 副作用不得整体丢失)。
542
745
  */
543
746
 
544
747
  declare function $async(thunk: () => Abs): Abs;
@@ -562,8 +765,11 @@ declare function $asyncReturn(v: Abs): Abs;
562
765
  * Bug 53:侧表/next() 消费完整收集序列(ys.els)——$arr >cap widen 只影响
563
766
  * 形状槽(类型面),不再把 >8 yield 截断成单元素流。
564
767
  * Bug 52:yield 点 try 上下文(ys.ctxs,$yield 第二实参)随序列传递——
565
- * .return()/.throw() 挂起点语义见 makeGenObject。 */
566
- declare function $gen(body: () => Abs): Abs;
768
+ * .return()/.throw() 挂起点语义见 makeGenObject。
769
+ * Bug 141:asyncMode(第二实参)= async generator 面——迭代结果经 promise
770
+ * 交付(next/return/throw 返 promise)、装 @@asyncIterator 自返槽与
771
+ * @@toStringTag "AsyncGenerator"(原生 async function* / async * 方法)。 */
772
+ declare function $gen(body: () => Abs, asyncMode?: boolean): Abs;
567
773
  /** yield v:压入当前生成器收集器;表达式值用 unknown。
568
774
  * tryCtx(Bug 52)= transpile 静态标注的 yield 点 try 上下文位
569
775
  * (YIELD_TRY_FINALLY / YIELD_TRY_CATCH),.return()/.throw() 挂起点
@@ -655,8 +861,23 @@ type TranspileOptions = {
655
861
  maxLoopIters?: number;
656
862
  /** 方法/函数体内 this 的绑定名(transpile class 时注入) */
657
863
  thisParam?: string;
864
+ /**
865
+ * Bug 1160:本转译单元**共享**的 this 载体名(`__this` 基名经
866
+ * `internalTmpName` 分配)。载体是跨发射器协议——真函数体 prologue
867
+ * (`let <名> = $rawThis(this)`)与类/对象方法、访问器 thunk、字段 /
868
+ * 静态块 thunk 的首参**一方声明、多方读**(读方即 `thisParam`)——必须
869
+ * 同名。根转译单元(`transpileFile` / `transpileBodyNode`)分配一次并
870
+ * 线程化;无碰撞时基名 `__this` 原样返回 ⇒ 产物逐字不变。
871
+ */
872
+ thisSlot?: string;
658
873
  /** 当前类名(super 派发用) */
659
874
  className?: string;
875
+ /**
876
+ * Bug 133:类表达式的 **NamedEvaluation 名**(`const K = class {}` → "K")。
877
+ * 只对**本表达式自身**生效——类体内的嵌套类表达式拿不到该名(原生内层
878
+ * 仍是无名类);类自身的名字(`class Named {}`)优先于绑定名。
879
+ */
880
+ classNameHint?: string;
660
881
  /**
661
882
  * 静态方法体内 super 的接收者源(父类构造器——extends 表达式经
662
883
  * classSpecOf 前移计算注入)。super.x / super.m() / super[k] 落通用
@@ -670,11 +891,17 @@ type TranspileOptions = {
670
891
  replacements?: Array<{
671
892
  target: string;
672
893
  varName: string;
673
- /** 仅该语句范围内生效(1-based 行) */
894
+ /**
895
+ * 仅该**节点**范围内生效——字符区间 `[stmtStart, stmtEnd)`
896
+ * (Babel 节点的 start/end 偏移),**不是行号**:Bug 166 修法把
897
+ * 「行号窗口」改成「AST 节点身份」,行号窗口会泄漏进嵌套/同行的
898
+ * 其它子表达式。
899
+ */
674
900
  stmtStart?: number;
675
901
  stmtEnd?: number;
676
902
  }>;
677
- /** @nudo:as:覆盖紧随语句的 init / return */
903
+ /** @nudo:as:覆盖紧随语句的 init / return(stmtStart/stmtEnd = 字符区间,
904
+ * 语义同上——按节点身份定位,不按行号) */
678
905
  asOverrides?: Array<{
679
906
  varName: string;
680
907
  stmtStart: number;
@@ -692,6 +919,19 @@ type TranspileOptions = {
692
919
  lenientGlobals?: boolean;
693
920
  /** try 嵌套深度(>0 时 return 前 drain throwExits,使 catch 能吸收抽象 throw) */
694
921
  inTry?: number;
922
+ /**
923
+ * 「块完成 ≠ 函数尾」深度(>0 时**早退提升**走控制流协议而非「返回值」
924
+ * 协议)。
925
+ *
926
+ * 族 65 · BC #28:try / catch / finally **块体**的完成不是函数尾(块跑完
927
+ * 后函数继续往下走)⇒ 早退提升(fn-body.ts)的 alt 臂(后续路径)跑完后
928
+ * **不得**把它的值当函数返回值抛出。此前只有 `inTry` 计入 inCtrl ⇒ catch /
929
+ * finally 体(inTry 不加)落「返回值」协议(`return $fork(...)`)⇒ 后续
930
+ * 路径的值被当成函数返回值(自信的错值)。
931
+ *
932
+ * 与 `inTry` 分开:inTry 另有职责(return 前 drain throwExits)。
933
+ */
934
+ inCtrlBlock?: number;
695
935
  /** 当前 try 的 mark 变量名(return drain 用;避免全局栈顶污染) */
696
936
  tryMarkName?: string;
697
937
  /** 当前 try 是否带 catch handler(soft may-throw digest/release 分支) */
@@ -707,6 +947,40 @@ type TranspileOptions = {
707
947
  yieldTryCtx?: number;
708
948
  /** 分支/循环体内深度(赋值记录 conditional 标记;inLoop 也计入) */
709
949
  conditionalFlow?: number;
950
+ /**
951
+ * 当前处在 **async 函数体**内(Bug 201)。
952
+ *
953
+ * async 体内的 `await` 是**真挂起点**:发射 `yield <operand>`(宿主生成器
954
+ * 挂起),由 `$asyncGen` 驱动恢复 ⇒ await 之后的语句不在调用点内联跑完
955
+ * (原生:恢复点是微任务)。
956
+ *
957
+ * 函数/方法体边界重置:async 体 ⇒ true;**非** async 体 ⇒ false(嵌套
958
+ * 同步函数不得继承——它不是生成器,`yield` 会是语法错误)。
959
+ */
960
+ inAsyncBody?: boolean;
961
+ /**
962
+ * **强制关闭** async 体的生成器路径(`$async` 同步路径)。
963
+ *
964
+ * Bug 1139(安全网):`await` 的位置表(`async-plan.ts`)与转译侧一旦脱节,
965
+ * `yield` 会落进嵌套箭头 ⇒ `new Function` SyntaxError ⇒ **整个模块**编译
966
+ * 失败 ⇒ 全部导出丢失 ⇒ L2 闸门**假绿**(exit 0)。求值引擎在生成器模式
967
+ * 编译失败时以本开关**重试一次** ⇒ 模块至少编译得出来 ⇒ 导出可见 ⇒ 闸门
968
+ * 照常判定(宁可少精确,不可整模块消失)。
969
+ */
970
+ disableAsyncGen?: boolean;
971
+ /**
972
+ * 当前 async 体内**需发挂起门**的 `for await` 语句节点(节点身份)。
973
+ *
974
+ * Bug 201:原生 `for await` 每轮一个 await;引擎既有建模是同步驱动 ⇒
975
+ * 生成器级发**整循环一个**挂起门(循环前 `yield`)。只有落在**生成器级**
976
+ * 位置(生成器体内联)的 for await 才能发门——分支臂/循环体里的 for await
977
+ * 是宿主 thunk(`yield` 会是语法错误)⇒ 由 async-plan 判定排除。
978
+ *
979
+ * 键 = 源偏移量(`String(node.start)`)——转译侧会**浅拷贝**语句节点
980
+ * (completeElseChains / flattenEarlyReturnBlocks)⇒ 节点身份不稳定,
981
+ * 源偏移量在拷贝间稳定。
982
+ */
983
+ asyncForAwaitGates?: ReadonlySet<string>;
710
984
  /** 函数/箭头体内(顶层绑定表只收顶层作用域) */
711
985
  inFunction?: boolean;
712
986
  /**
@@ -739,6 +1013,17 @@ type TranspileOptions = {
739
1013
  * 成员/下标写对根的内部重绑不在用户赋值路径,不走此表。
740
1014
  */
741
1015
  constNames?: ReadonlySet<string>;
1016
+ /**
1017
+ * **调用方补给的**用户标识符词形集(Bug 1058 避让的补充来源)。
1018
+ *
1019
+ * `internalTmpName` 的避让集 = `userIdentInfo(opts.source).names`(源文本
1020
+ * 词形)∪ 本集合。用于**没有源文本**的转译单元——`exec/body-fn.ts` 的
1021
+ * body 编译路径(`transpileBodyNode(impl.body, …)` 原先传空 opts ⇒ 无
1022
+ * source ⇒ 避让集恒空 ⇒ 引擎内部临时名与用户标识符相撞 ⇒ 产物非法 JS
1023
+ * ⇒ 整模块 fail-closed)。该路径的调用方从 **AST** 收标识符词形
1024
+ * (body 内全部 Identifier + 形参名)补进来。
1025
+ */
1026
+ userIdents?: ReadonlySet<string>;
742
1027
  /**
743
1028
  * 本作用域已提升到函数体顶部的 var 名(Bug 21):块内 `var x = init`
744
1029
  * 改发赋值 `x = init`(绑定由顶部 `let x = $lit(void 0)` 提供)。
@@ -779,6 +1064,14 @@ type TranspileOptions = {
779
1064
  /**
780
1065
  * transpile 共享 AST 工具:形参名、match、fold、静态键、作用域收集、mutator receiver 扫描。
781
1066
  * 不依赖 stmt/expr 发射器(无环)。
1067
+ *
1068
+ * 不变量(@nudo:as / @nudo:replace 指令面):
1069
+ * - **作用范围按 AST 节点身份**(源文本字符区间 [start, end))判定,
1070
+ * 不是「同一行号窗口」:多行语句 / 嵌套块 / 同行下一条语句都不再被命中
1071
+ * (Bug 166)。as 的目标是**承载指令的那条语句**;replace 的目标是该
1072
+ * 语句子树内、**不跨作用域边界**的子表达式节点(边界在收集面划定)。
1073
+ * - **replace 命中的子表达式仍要求值**(副作用与 throws 域保留),只是
1074
+ * 结果被注入值取代(Bug 165);旧口径整段替换 → 副作用与抛错域消失。
782
1075
  */
783
1076
 
784
1077
  /**
@@ -800,6 +1093,14 @@ declare function foldRequireSpecArg(arg: unknown): string | undefined;
800
1093
  * (emitFnBlockBody / transpileFnBodyStmts)——逐语句 map(transpileStatement)
801
1094
  * 会绕过早退 if 提升,`if (c) return X; return Y` 的早退值被语句级 $fork
802
1095
  * thunk 吞掉(假精确);
1096
+ * - 早退提升的 alt 臂 = **后续路径**(事实臂已 return/throw 提前退出 ⇒ 测试
1097
+ * 为假)⇒ 该臂**不断言否定关系界**(Bug 1115:¬(x <= k) 含 NaN,不可健全
1098
+ * 表示 ⇒ 断言否定界会把 NaN 排除 ⇒ 假绿;事实臂窄化不受影响);
1099
+ * - 早退摊平的**送达范围**(Bug 186):内含早退 if 且**无词法声明**的块
1100
+ * 摊平到当前语句表(flattenEarlyReturnBlocks)——块正常完成 ⇒ 早退测试为
1101
+ * 假;块内有词法声明时不摊平(作用域不外泄);
1102
+ * - try / catch / finally 的**块体**也走本入口(与函数体顶层同口径)——裸
1103
+ * map(transpileStatement) 会绕过早退提升;
803
1104
  * - 函数体边界 var 提升(Bug 21):skip = 参数模式名;嵌套块不传
804
1105
  * varScope(var 已在函数级提升,块内改发赋值);
805
1106
  * - P4b 参数遮蔽:继承 constNames 被本函数参数模式名遮蔽时扣除(假
@@ -808,6 +1109,23 @@ declare function foldRequireSpecArg(arg: unknown): string | undefined;
808
1109
  * (Bug 9:先用后声明时 new g() 不误判)。
809
1110
  */
810
1111
 
1112
+ /**
1113
+ * 关系守卫的**补集**精化已**整体撤销**(Bug 1115)。
1114
+ *
1115
+ * 原实现(Bug 182)在「测试为假」的后续路径上断言**否定关系界**
1116
+ * (`x <= k` 为假 ⇒ `x > k`,`REL_COMPLEMENT_OP`)——但 JS 里
1117
+ * `¬(x <= k)` 还含 `x` 为 NaN 的情形(NaN 与任何比较皆假):
1118
+ * 后续路径只能断定 `x > k ∨ x is NaN` ⇒ 断言 `x > k` **排除了 NaN**
1119
+ * (不健全)⇒
1120
+ * - `if (x < 0) return 0; return x;` + `return nonNeg`:后续路径断言
1121
+ * `x >= 0` ⇒ 契约被「证成」⇒ **0 诊断**(假绿);原生 x=NaN ⇒
1122
+ * `NaN < 0` 为假 ⇒ `return x` ⇒ 返回 NaN ⇒ 违反 nonNeg(真违规)。
1123
+ * - 三元写法 `return x < 0 ? 0 : x;` 的 else 臂没有否定界窄化 ⇒ 判
1124
+ * `unproven-return` ⇒ 两种等价写法结论不一致。
1125
+ *
1126
+ * ⇒ 后续路径**不断言否定界**(事实臂 `narrowRelArmThunk` 保留:那一侧
1127
+ * 「测试为真」⇒ NaN 不可达,断言是健全的)。
1128
+ */
811
1129
  declare function transpileBodyNode(node: Node, opts: TranspileOptions): string;
812
1130
 
813
1131
  /**
@@ -839,6 +1157,12 @@ declare function transpileExpression(expr: Expression, opts?: TranspileOptions):
839
1157
  *
840
1158
  * 实现按语句/表达式/模式拆在 transpile/*.ts;本文件是 re-export facade,
841
1159
  * 对外符号面保持不变(exec/index.ts `export * from "./transpile.ts"`)。
1160
+ *
1161
+ * 不变量(解构临时名,Bug 181):
1162
+ * - 模块级解构临时名计数器(`destrTmpSeq`)在**创建处**即预置避让:序号
1163
+ * 推过用户已占用的 `_d{n}` / `_n{n}` ⇒ 首次分配(模块首条语句即解构
1164
+ * 声明)也拿不到与用户同名绑定重复的临时名(重复词法声明 ⇒ SyntaxError
1165
+ * ⇒ 整模块求值失败 ⇒ 导出退化 unknown)。
842
1166
  */
843
1167
 
844
1168
  declare function transpileSource(source: string, opts?: TranspileOptions): string;
@@ -877,10 +1201,19 @@ type EvalClassSpec = {
877
1201
  methods?: Record<string, (thisVal: Abs, ...args: Abs[]) => Abs>;
878
1202
  /** 实例方法形参展示名(AST 形参名;未调用方法槽 `shape.params` 用) */
879
1203
  methodParams?: Record<string, string[]>;
1204
+ /**
1205
+ * Bug 325:实例方法的**函数种类**戳(async × generator 四象限)——
1206
+ * 原生类方法的标签面(Object.prototype.toString.call(A.prototype.m))
1207
+ * 随 async / generator 变("[object AsyncFunction]" 等)。类方法**同时**
1208
+ * 可能是 generator ⇒ 与 impl.kind 的派发角色维度分开承载。
1209
+ */
1210
+ methodKinds?: Record<string, "function" | "async" | "generator" | "async-generator">;
880
1211
  /** R5:静态方法 impl 首参 __this = 类值(接收者——沿链调用时是调用类) */
881
1212
  staticMethods?: Record<string, (thisVal: Abs, ...args: Abs[]) => Abs>;
882
1213
  /** 静态方法形参展示名 */
883
1214
  staticMethodParams?: Record<string, string[]>;
1215
+ /** Bug 325:静态方法的函数种类戳(实例方法同口径) */
1216
+ staticMethodKinds?: Record<string, "function" | "async" | "generator" | "async-generator">;
884
1217
  /**
885
1218
  * P2b:构造器元数(首个默认值/rest 形参前的形参数,nativeParamArity
886
1219
  * 口径)——类值 .length 自有属性。隐式构造器(基类零参 / 派生
@@ -938,11 +1271,13 @@ declare function clearBClasses(): void;
938
1271
  * withNewTargetReset 包裹(嵌套 new 不串帧)。
939
1272
  */
940
1273
 
941
- /** 定义类 → 可 new 的 Abs(brand 标记;静态字段挂在 slots) */
1274
+ /** 定义类 → 可 new 的 Abs(brand 标记;静态字段挂在 slots)。
1275
+ * displayName(Bug 133):对外可见的 **name**(原生无名类名为空串);缺省
1276
+ * 用内部类名(类声明 / 具名类表达式同口径)。 */
942
1277
  declare function $class(name: string, spec: Omit<EvalClassSpec, "name"> & {
943
1278
  extends?: string | Abs | unknown;
944
1279
  hasExtends?: boolean;
945
- }): Abs;
1280
+ }, displayName?: string): Abs;
946
1281
  /** new C(...) → 空 brand 实例 + ctor 写字段;非类构造走 impl/$call */
947
1282
  declare function $new(cls: Abs | ((...a: unknown[]) => unknown), args: Abs[]): Abs;
948
1283
  /**
@@ -1019,15 +1354,22 @@ declare function $setSuperStatic(thisVal: Abs, childName: string, key: Abs, valu
1019
1354
  * - 数组方法(map/filter/reduce/…)委派 invokeArrMethod(invoke-arr.ts);
1020
1355
  * mutator 语句快路径在 transpile 层(emitArrMutatorRebinds),两条路径
1021
1356
  * 的元素域语义必须同口径(issue #153:SpreadElement 折 $unknown 的教训)。
1357
+ * - Bug 152:实参可以是 **thunk**(`() => [args]`)——调用点成员**先于实参**
1358
+ * 求值(原生 CallExpression 顺序:引用取值(getter 在此触发)→ 实参 →
1359
+ * 调用)。thunk 形态:$invoke 先读成员(预读),再求实参,最后派发;
1360
+ * 派发复用预读值(不再二次读 ⇒ getter 只跑一次)。预读对 sum(union)
1361
+ * 接收者跳过(派发按成员各读一次,预读会重复触发 getter)。
1022
1362
  */
1023
1363
 
1024
1364
  /** 实例方法调用:沿继承链;类 Abs 上回落 staticMethods;obj 上回落属性函数 */
1025
- declare function $invoke(thisVal: Abs, method: string, args: Abs[], loc?: [number, number]): Abs;
1365
+ declare function $invoke(thisVal: Abs, method: string, args: Abs[] | (() => Abs[]), loc?: [number, number]): Abs;
1026
1366
  /** obj[key]():计算键成员调用(键运行时求值)。键折叠成槽名后走 $invoke
1027
1367
  * 既有派发;@@iterator 键按接收者形态折迭代器对象。键不可折叠(抽象键 /
1028
1368
  * 用户 symbol)→ 诚实 unknown(与 $call 对 unknown callee 同口径——
1029
- * unknown 是 fail-closed 令牌,不记 may-throw)。 */
1030
- declare function $invokeKey(thisVal: Abs, key: Abs, args: Abs[], loc?: [number, number]): Abs;
1369
+ * unknown 是 fail-closed 令牌,不记 may-throw)。
1370
+ * Bug 152:实参 thunk 形态(`() => [args]`)——键求值后**先读成员**再求
1371
+ * 实参(原生顺序:键 → 引用取值 → 实参 → 调用)。 */
1372
+ declare function $invokeKey(thisVal: Abs, key: Abs, args: Abs[] | (() => Abs[]), loc?: [number, number]): Abs;
1031
1373
  /** 可选链计算键调用(a?.[k]() / a[k]?.() 的非链路径):nullish 接收者
1032
1374
  * 短路 undefined 字面量($optionalInvoke 同口径);键折叠与派发同
1033
1375
  * $invokeKey。 */
@@ -1049,8 +1391,12 @@ declare function $thisSet(thisVal: Abs, key: string, value: Abs): Abs;
1049
1391
  /** 解构默认值:undefined(含 sum 成员 / 可能缺失)时用 default 并入非 undefined 部分 */
1050
1392
  declare function $orDefault(v: Abs, dflt: () => Abs): Abs;
1051
1393
  /** 可选链 a?.b:nullish 短路为 undefined 字面量。非 nullish 臂的属性读对
1052
- * 非 nullish 值原生不抛 → silent(不记 any may-throw,Bug 3) */
1053
- declare function $optionalGet(o: Abs, key: string): Abs;
1394
+ * 非 nullish 值原生不抛 → silent(不记 any may-throw,Bug 3)。
1395
+ * opts.symbolKey(Bug 149):键来自符号投影("[Symbol.X]" → "@@X")——
1396
+ * 陷阱边界把 "@@X" 还原成真 symbol(规范 PropertyKey)。 */
1397
+ declare function $optionalGet(o: Abs, key: string, opts?: {
1398
+ symbolKey?: boolean;
1399
+ }): Abs;
1054
1400
  /** 可选链 a?.m():nullish 短路为 undefined */
1055
1401
  declare function $optionalInvoke(thisVal: Abs, method: string, args: Abs[]): Abs;
1056
1402
  /** 静态方法:cls.staticMethod(args) */
@@ -1092,4 +1438,4 @@ declare class NudoUnsupportedError extends Error {
1092
1438
  detail?: string);
1093
1439
  }
1094
1440
 
1095
- export { $absVal, $add, $arguments, $arr, $arrMutContainer, $arrRest, $arrWithHoles, $async, $asyncReturn, $await, $bitand, $bitnot, $bitor, $bitxor, $catchVal, $class, $classExpr, $collectionForEach, $concat, $copy, $del, $delRes, $div, $dynamicImport, $elems, $eq, $eqLoose, $fnVal, $for, $forInKeys, $forIter, $forOf, $fork, $ge, $gen, $get, $getSuper, $getSuperObj, $gt, $idx, $idxSet, $importMeta, $in, $instanceof, $instanceofNonIdent, $invoke, $invokeKey, $invokeSuper, $invokeSuperKey, $invokeSuperObj, $isBreakTo, $isForkExit, $iterCheck, $join, $le, $len, $lit, $loopBreak, $loopContinue, $loopReturn, $lt, $mod, $mul, $narrowMemberEq, $narrowTypeOf, $ne, $neLoose, $neg, $new, $newTarget, $not, $nullishTest, $obj, $objAccessor, $objAccessorKey, $objRest, $optionalGet, $optionalInvoke, $optionalInvokeKey, $orDefault, $pow, $pushLoopExit, $rawThis, $reStateCall, $refineRel, $regex, $removeMemberNullish, $removeNull, $removeNullish, $removeUndefined, $restBind, $rethrowIfNudoReturn, $set, $setKey, $setProto, $setSuper, $setSuperObj, $setSuperStatic, $shl, $shr, $spread, $staticInit, $staticInvoke, $staticSuperInvoke, $sub, $super, $switch, $thisGet, $thisSet, $throw, $toNumber, $toNumeric, $tpl, $tryCurrentMark, $tryDetachSoftCatch, $tryDigestSoftCatch, $tryDiscardSoft, $tryMark, $tryOrphanSoft, $tryPopMark, $tryReleaseSoftCatch, $tryReleaseSoftOut, $tryTakeSince, $typeof, $unknown, $updateAdd, $updateSub, $ushr, $while, $whileSeq, $yield, $yieldStar, DEFAULT_MAX_LOOP_ITERS, type EvalClassSpec, NudoLoopSignal, NudoReturn, NudoThrow, NudoUnsupportedError, type TranspileOptions, asAbsVal, callAtFunctionBoundary, clearBClasses, clearStaleTermPred, currentAssumePremises, 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, withAssumePremises, withExecPhi };
1441
+ export { $absVal, $add, $arguments, $arr, $arrMutContainer, $arrRest, $arrWithHoles, $async, $asyncReturn, $await, $bitand, $bitnot, $bitor, $bitxor, $catchVal, $class, $classExpr, $collectionForEach, $concat, $copy, $del, $delRes, $div, $dynamicImport, $elems, $eq, $eqLoose, $fnKindStamp, $fnVal, $for, $forInKeys, $forIter, $forOf, $fork, $ge, $gen, $get, $getSuper, $getSuperObj, $gt, $idx, $idxSet, $importMeta, $in, $instanceof, $instanceofNonIdent, $invoke, $invokeKey, $invokeSuper, $invokeSuperKey, $invokeSuperObj, $isBreakTo, $isForkExit, $iterCheck, $join, $le, $len, $lit, $loopBreak, $loopContinue, $loopReturn, $lt, $mod, $mul, $narrowMemberEq, $narrowTypeOf, $ne, $neLoose, $neg, $new, $newTarget, $not, $nullishTest, $obj, $objAccessor, $objAccessorKey, $objRest, $optionalGet, $optionalInvoke, $optionalInvokeKey, $orDefault, $pow, $pushLoopExit, $rawThis, $reStateCall, $refineRel, $regex, $removeMemberNullish, $removeNull, $removeNullish, $removeUndefined, $restBind, $rethrowIfNudoReturn, $set, $setKey, $setProto, $setSuper, $setSuperObj, $setSuperStatic, $shl, $shr, $spread, $staticInit, $staticInvoke, $staticSuperInvoke, $sub, $super, $switch, $thisGet, $thisSet, $throw, $toNumber, $toNumeric, $tpl, $tryCurrentMark, $tryDetachSoftCatch, $tryDigestSoftCatch, $tryDiscardSoft, $tryMark, $tryOrphanSoft, $tryPopMark, $tryReleaseSoftCatch, $tryReleaseSoftOut, $tryTakeSince, $typeof, $unknown, $updateAdd, $updateSub, $ushr, $while, $whileSeq, $yield, $yieldStar, DEFAULT_MAX_LOOP_ITERS, type EvalClassSpec, NudoLoopSignal, NudoReturn, NudoThrow, NudoUnsupportedError, type TranspileOptions, asAbsVal, callAtFunctionBoundary, clearBClasses, clearStaleTermPred, currentAssumePremises, 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, withAssumePremises, withExecPhi };