@scriptc/compiler 0.0.7 → 0.0.8

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.
Files changed (68) hide show
  1. package/dist/backend/emission/emit-exprs.js +47 -1
  2. package/dist/backend/emission/emit-exprs.js.map +1 -1
  3. package/dist/backend/emission/emit-island.js +9 -1
  4. package/dist/backend/emission/emit-island.js.map +1 -1
  5. package/dist/backend/emission/emit-stmts.js +3 -1
  6. package/dist/backend/emission/emit-stmts.js.map +1 -1
  7. package/dist/backend/emission/emit-walkers.js +22 -8
  8. package/dist/backend/emission/emit-walkers.js.map +1 -1
  9. package/dist/backend/emission/emitter.js +5 -1
  10. package/dist/backend/emission/emitter.js.map +1 -1
  11. package/dist/backend/emission/may-throw.js +4 -3
  12. package/dist/backend/emission/may-throw.js.map +1 -1
  13. package/dist/backend/llvm/emitter.js +94 -7
  14. package/dist/backend/llvm/emitter.js.map +1 -1
  15. package/dist/diagnostics/diagnostic.d.ts +43 -1
  16. package/dist/diagnostics/diagnostic.js +103 -5
  17. package/dist/diagnostics/diagnostic.js.map +1 -1
  18. package/dist/frontend/lib-contract.d.ts +24 -6
  19. package/dist/frontend/lib-contract.js +125 -44
  20. package/dist/frontend/lib-contract.js.map +1 -1
  21. package/dist/frontend/lowering/lower-builtins.js +16 -1
  22. package/dist/frontend/lowering/lower-builtins.js.map +1 -1
  23. package/dist/frontend/lowering/lower-calls.d.ts +47 -7
  24. package/dist/frontend/lowering/lower-calls.js +560 -36
  25. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  26. package/dist/frontend/lowering/lower-classes.d.ts +14 -1
  27. package/dist/frontend/lowering/lower-classes.js +85 -15
  28. package/dist/frontend/lowering/lower-classes.js.map +1 -1
  29. package/dist/frontend/lowering/lower-containers.js +43 -1
  30. package/dist/frontend/lowering/lower-containers.js.map +1 -1
  31. package/dist/frontend/lowering/lower-emitter.js +1 -1
  32. package/dist/frontend/lowering/lower-emitter.js.map +1 -1
  33. package/dist/frontend/lowering/lower-exprs.d.ts +26 -3
  34. package/dist/frontend/lowering/lower-exprs.js +455 -40
  35. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  36. package/dist/frontend/lowering/lower-island.d.ts +7 -0
  37. package/dist/frontend/lowering/lower-island.js +71 -10
  38. package/dist/frontend/lowering/lower-island.js.map +1 -1
  39. package/dist/frontend/lowering/lower-mixins.d.ts +1 -1
  40. package/dist/frontend/lowering/lower-mixins.js +1 -1
  41. package/dist/frontend/lowering/lower-modules.js +95 -4
  42. package/dist/frontend/lowering/lower-modules.js.map +1 -1
  43. package/dist/frontend/lowering/lower-stmts.js +421 -43
  44. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  45. package/dist/frontend/lowering/lowerer.d.ts +19 -3
  46. package/dist/frontend/lowering/lowerer.js +188 -11
  47. package/dist/frontend/lowering/lowerer.js.map +1 -1
  48. package/dist/frontend/types.d.ts +28 -1
  49. package/dist/frontend/types.js +300 -8
  50. package/dist/frontend/types.js.map +1 -1
  51. package/dist/index.d.ts +2 -1
  52. package/dist/index.js +37 -7
  53. package/dist/index.js.map +1 -1
  54. package/dist/ir/nodes.d.ts +28 -2
  55. package/dist/ir/nodes.js +35 -3
  56. package/dist/ir/nodes.js.map +1 -1
  57. package/dist/ir/validate.js +35 -6
  58. package/dist/ir/validate.js.map +1 -1
  59. package/dist/library/profile.d.ts +17 -3
  60. package/dist/library/profile.js +38 -9
  61. package/dist/library/profile.js.map +1 -1
  62. package/dist/library/sidecar.js +162 -43
  63. package/dist/library/sidecar.js.map +1 -1
  64. package/dist/library/trap-teaching.d.ts +11 -0
  65. package/dist/library/trap-teaching.js +49 -0
  66. package/dist/library/trap-teaching.js.map +1 -0
  67. package/package.json +2 -2
  68. package/surface-manifest.json +37 -2
@@ -49,7 +49,7 @@ export function lowerArrayMethodCall(L, call, access) {
49
49
  return null;
50
50
  if (!probedUntyped && !L.isStdlibMember(access))
51
51
  return null;
52
- const elem = receiverIr.elem;
52
+ let elem = receiverIr.elem;
53
53
  const loc = locOf(call);
54
54
  // An island handle behind an array-typed .d.ts surface
55
55
  // (`parts().join("-")` — arrays never exit eagerly, so the value
@@ -91,6 +91,19 @@ export function lowerArrayMethodCall(L, call, access) {
91
91
  }
92
92
  L.noLowering(`.${name} on an array value held in a checked-dynamic binding`, call, "assign it to an array-typed binding first (the validated extraction), then call the method");
93
93
  }
94
+ // An evolving-`any` array binding under --dynamic whose flow type
95
+ // EVOLVED past `any[]` (`const fns = []; fns.push(() => 1);
96
+ // fns.map(...)` — the binding lowered array<jsval> at its `any[]`
97
+ // declaration, while tsc's evolving-array analysis answers the
98
+ // pushed element type at this site): the VALUE's element type is
99
+ // the truth — ride the explicit-`any[]` handle-element lowering
100
+ // (pushes marshal in, HOF callbacks bind the handle, results exit
101
+ // per the checker type), never a typed intrinsic over a jsval-
102
+ // element array (the validator ICE).
103
+ if (receiver.type.kind === "array" && receiver.type.elem.kind === "jsval" && !typeEquals(receiverIr, receiver.type)) {
104
+ receiverIr = receiver.type;
105
+ elem = receiver.type.elem;
106
+ }
94
107
  }
95
108
  if (name === "sort")
96
109
  return lowerArraySortCall(L, call, access, elem, receiverIr);
@@ -214,6 +227,20 @@ export function lowerArrayMethodCall(L, call, access) {
214
227
  args.push(arg);
215
228
  continue;
216
229
  }
230
+ // A handle-element receiver given an argument whose CHECKER type
231
+ // spells evolved elements while its VALUE is a jsval-element
232
+ // array (`fns.concat(tail)` — both sides of the evolving-`any`
233
+ // adoption): the value's array-ness decides, exactly JS's
234
+ // IsArray — spread it. Non-array values fall through to the
235
+ // element push (the jsvalIn coercion).
236
+ if (elem.kind === "jsval") {
237
+ const arg = L.lowerExpr(argNode);
238
+ if (arg.type.kind === "array" && arg.type.elem.kind === "jsval") {
239
+ shape.push("a");
240
+ args.push(arg);
241
+ continue;
242
+ }
243
+ }
217
244
  // An element value — union elements wrap exactly like a push.
218
245
  shape.push("e");
219
246
  args.push(L.lowerExprExpecting(argNode, elem));
@@ -324,6 +351,21 @@ function hofCallbackArg(L, argNode, lead, arrT) {
324
351
  }
325
352
  }
326
353
  }
354
+ // A JSVAL-element receiver behind an EVOLVED contextual type (the
355
+ // evolving-`any` array under --dynamic — lowerArrayMethodCall adopted
356
+ // the value's handle element while tsc's evolving analysis types the
357
+ // callback's params by the pushed elements): the lead params BIND the
358
+ // handles the loop passes, whatever the contextual type spelled —
359
+ // paramShape's island-handle early-out, the then-handler rule.
360
+ if (ts.isArrowFunction(argNode) || ts.isFunctionExpression(argNode)) {
361
+ argNode.parameters.forEach((p, i) => {
362
+ if (i >= lead.length || lead[i].kind !== "jsval")
363
+ return;
364
+ if (!ts.isIdentifier(p.name) || p.type || p.initializer || p.dotDotDotToken)
365
+ return;
366
+ L.jsvalParamOverrides.add(p);
367
+ });
368
+ }
327
369
  let fnArg;
328
370
  try {
329
371
  fnArg = L.lowerExpr(argNode);