@danielx/civet 0.8.4 → 0.8.5

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/main.js CHANGED
@@ -1058,6 +1058,9 @@ function makeLeftHandSideExpression(expression) {
1058
1058
  expression = item;
1059
1059
  }
1060
1060
  if (isASTNodeObject(expression)) {
1061
+ if (expression.token) {
1062
+ return expression;
1063
+ }
1061
1064
  if (expression.parenthesized) {
1062
1065
  return expression;
1063
1066
  }
@@ -1580,86 +1583,90 @@ function gatherBindingPatternTypeSuffix(pattern) {
1580
1583
  let count = 0;
1581
1584
  switch (pattern.type) {
1582
1585
  case "ArrayBindingPattern": {
1583
- const results = [];
1584
- for (let ref2 = pattern.elements, i2 = 0, len1 = ref2.length; i2 < len1; i2++) {
1585
- const elem = ref2[i2];
1586
- let { typeSuffix } = elem;
1587
- typeSuffix ??= elem.binding?.typeSuffix;
1588
- if (typeSuffix) {
1589
- count++;
1590
- }
1591
- let typeElement = [typeSuffix?.t, elem.delim];
1592
- if (typeSuffix?.optional) {
1593
- typeElement[0] = parenthesizeType(typeElement[0]);
1594
- typeElement.unshift("undefined |");
1586
+ {
1587
+ const results = [];
1588
+ for (let ref2 = pattern.elements, i2 = 0, len1 = ref2.length; i2 < len1; i2++) {
1589
+ const elem = ref2[i2];
1590
+ let { typeSuffix } = elem;
1591
+ typeSuffix ??= elem.binding?.typeSuffix;
1592
+ if (typeSuffix) {
1593
+ count++;
1594
+ }
1595
+ let typeElement = [typeSuffix?.t, elem.delim];
1596
+ if (typeSuffix?.optional) {
1597
+ typeElement[0] = parenthesizeType(typeElement[0]);
1598
+ typeElement.unshift("undefined |");
1599
+ }
1600
+ if (elem.type === "BindingRestElement") {
1601
+ typeElement[0] ??= "unknown[]";
1602
+ typeElement.unshift(elem.dots);
1603
+ } else {
1604
+ typeElement[0] ??= "unknown";
1605
+ }
1606
+ results.push(typeElement);
1595
1607
  }
1596
- if (elem.type === "BindingRestElement") {
1597
- typeElement[0] ??= "unknown[]";
1598
- typeElement.unshift(elem.dots);
1599
- } else {
1600
- typeElement[0] ??= "unknown";
1608
+ ;
1609
+ const types = results;
1610
+ if (count) {
1611
+ const t = [": [", types, "]"];
1612
+ pattern.typeSuffix = {
1613
+ type: "TypeSuffix",
1614
+ ts: true,
1615
+ t,
1616
+ children: [t]
1617
+ };
1601
1618
  }
1602
- results.push(typeElement);
1603
- }
1604
- ;
1605
- const types = results;
1606
- if (count) {
1607
- const t = [": [", types, "]"];
1608
- pattern.typeSuffix = {
1609
- type: "TypeSuffix",
1610
- ts: true,
1611
- t,
1612
- children: [t]
1613
- };
1614
1619
  }
1615
1620
  ;
1616
1621
  break;
1617
1622
  }
1618
1623
  case "ObjectBindingPattern": {
1619
- let restType;
1620
- const results1 = [];
1621
- for (let ref3 = pattern.properties, i3 = 0, len22 = ref3.length; i3 < len22; i3++) {
1622
- const prop = ref3[i3];
1623
- let { typeSuffix } = prop;
1624
- typeSuffix ??= prop.value?.typeSuffix;
1625
- if (typeSuffix) {
1626
- count++;
1627
- }
1628
- typeSuffix ??= {
1629
- type: "TypeSuffix",
1630
- ts: true,
1631
- children: [": unknown"]
1632
- };
1633
- switch (prop.type) {
1634
- case "BindingProperty": {
1635
- const ws = prop.children.slice(0, prop.children.indexOf(prop.name));
1636
- results1.push([...ws, prop.name, typeSuffix, prop.delim]);
1637
- break;
1638
- }
1639
- case "AtBindingProperty": {
1640
- const ws = prop.children.slice(0, prop.children.indexOf(prop.binding));
1641
- results1.push([...ws, prop.ref.id, typeSuffix, prop.delim]);
1642
- break;
1624
+ {
1625
+ let restType;
1626
+ const results1 = [];
1627
+ for (let ref3 = pattern.properties, i3 = 0, len22 = ref3.length; i3 < len22; i3++) {
1628
+ const prop = ref3[i3];
1629
+ let { typeSuffix } = prop;
1630
+ typeSuffix ??= prop.value?.typeSuffix;
1631
+ if (typeSuffix) {
1632
+ count++;
1643
1633
  }
1644
- case "BindingRestProperty": {
1645
- restType = prop.typeSuffix?.t;
1646
- continue;
1634
+ typeSuffix ??= {
1635
+ type: "TypeSuffix",
1636
+ ts: true,
1637
+ children: [": unknown"]
1638
+ };
1639
+ switch (prop.type) {
1640
+ case "BindingProperty": {
1641
+ const ws = prop.children.slice(0, prop.children.indexOf(prop.name));
1642
+ results1.push([...ws, prop.name, typeSuffix, prop.delim]);
1643
+ break;
1644
+ }
1645
+ case "AtBindingProperty": {
1646
+ const ws = prop.children.slice(0, prop.children.indexOf(prop.binding));
1647
+ results1.push([...ws, prop.ref.id, typeSuffix, prop.delim]);
1648
+ break;
1649
+ }
1650
+ case "BindingRestProperty": {
1651
+ restType = prop.typeSuffix?.t;
1652
+ continue;
1653
+ }
1647
1654
  }
1648
1655
  }
1649
- }
1650
- ;
1651
- const types = results1;
1652
- if (count) {
1653
- const t = ["{", types, "}"];
1654
- if (restType != null) {
1655
- t.push(" & ", parenthesizeType(trimFirstSpace(restType)));
1656
+ ;
1657
+ const types = results1;
1658
+ if (count) {
1659
+ const t = ["{", types, "}"];
1660
+ if (restType != null) {
1661
+ t.push(" & ", parenthesizeType(trimFirstSpace(restType)));
1662
+ }
1663
+ pattern.typeSuffix = {
1664
+ type: "TypeSuffix",
1665
+ ts: true,
1666
+ t,
1667
+ children: [": ", t]
1668
+ };
1656
1669
  }
1657
- pattern.typeSuffix = {
1658
- type: "TypeSuffix",
1659
- ts: true,
1660
- t,
1661
- children: [": ", t]
1662
- };
1663
1670
  }
1664
1671
  ;
1665
1672
  break;
@@ -1729,6 +1736,34 @@ var declareHelper = {
1729
1736
  "\n"
1730
1737
  ]]);
1731
1738
  },
1739
+ rslice(rsliceRef) {
1740
+ const RSliceable = makeRef("RSliceable");
1741
+ state.prelude.push(["", [
1742
+ ts(["type ", RSliceable, "<R> = string | {length: number; slice(start: number, end: number): {reverse(): R}}\n"]),
1743
+ preludeVar,
1744
+ rsliceRef,
1745
+ ts([": <R, T extends string | ", RSliceable, "<R>>(a: T, start?: number, end?: number) => T extends string ? string : T extends ", RSliceable, "<infer R> ? R : never"]),
1746
+ " = ((a, start, end) => {\n",
1747
+ " const l = a.length\n",
1748
+ " start = ",
1749
+ getHelperRef("modulo"),
1750
+ "(start ?? -1, l)\n",
1751
+ " end = ",
1752
+ getHelperRef("modulo"),
1753
+ "((end ?? -1) + 1, l)\n",
1754
+ " if (typeof a === 'string') {\n",
1755
+ ` let r = ""
1756
+ `,
1757
+ " for (let i = start; i >= end; --i) r += a[i]\n",
1758
+ " return r",
1759
+ asAny,
1760
+ "\n",
1761
+ " } else {\n",
1762
+ " return a.slice(end, start + 1).reverse()\n",
1763
+ " }\n",
1764
+ "});\n"
1765
+ ]]);
1766
+ },
1732
1767
  div(divRef) {
1733
1768
  state.prelude.push(["", [
1734
1769
  // [indent, statement]
@@ -1855,6 +1890,9 @@ function getHelperRef(base) {
1855
1890
  declareHelper[base](ref);
1856
1891
  return state.helperRefs[base] = ref;
1857
1892
  }
1893
+ function peekHelperRef(base) {
1894
+ return state.helperRefs[base];
1895
+ }
1858
1896
  function extractPreludeFor(node) {
1859
1897
  let helpers = new Set(Object.values(state.helperRefs));
1860
1898
  helpers = new Set(gatherRecursive(node, helpers.has.bind(helpers)));
@@ -5801,7 +5839,131 @@ function handleThisPrivateShorthands(value) {
5801
5839
  return [value, value.thisShorthand];
5802
5840
  }
5803
5841
  function processTryBlock($0) {
5804
- let [t, , b, c, e, f] = $0;
5842
+ let [t, , b, cs, e, f] = $0;
5843
+ let c;
5844
+ let m;
5845
+ if (cs.some(($) => (m = $.binding?.parameter, typeof m === "object" && m != null && "type" in m && m.type === "CatchPattern"))) {
5846
+ const ref = makeRef("e");
5847
+ const binding = {
5848
+ type: "CatchBinding",
5849
+ children: ["(", ref, ")"],
5850
+ parameter: ref
5851
+ };
5852
+ const condition = {
5853
+ type: "ParenthesizedExpression",
5854
+ children: ["(", ref, ")"],
5855
+ expression: ref
5856
+ };
5857
+ let defaultClause = false;
5858
+ const clauses = cs.map((clause) => {
5859
+ let ref1;
5860
+ if ((ref1 = clause.binding?.parameter) && typeof ref1 === "object" && "type" in ref1 && ref1.type === "CatchPattern" && "patterns" in ref1) {
5861
+ const { type, patterns } = ref1;
5862
+ return {
5863
+ type: "PatternClause",
5864
+ patterns,
5865
+ block: clause.block,
5866
+ children: [patterns, clause.block]
5867
+ };
5868
+ } else {
5869
+ defaultClause = true;
5870
+ const parameter = clause.binding?.parameter;
5871
+ if (parameter != null) {
5872
+ assert.equal(
5873
+ parameter.type,
5874
+ "CatchParameter",
5875
+ `Invalid catch parameter ${parameter.type}`
5876
+ );
5877
+ const { binding: pattern, typeSuffix } = parameter;
5878
+ const initializer = {
5879
+ type: "Initializer",
5880
+ expression: ref,
5881
+ children: ["", " = ", ref]
5882
+ };
5883
+ const bindings = [{
5884
+ type: "Binding",
5885
+ names: pattern.names,
5886
+ pattern,
5887
+ typeSuffix,
5888
+ initializer,
5889
+ children: [pattern, typeSuffix, initializer],
5890
+ splices: [],
5891
+ thisAssignments: []
5892
+ }];
5893
+ clause.block.expressions.unshift(["", {
5894
+ type: "Declaration",
5895
+ children: ["let", " ", bindings],
5896
+ bindings,
5897
+ names: bindings[0].names,
5898
+ decl: "let"
5899
+ }, ";"]);
5900
+ }
5901
+ return {
5902
+ type: "DefaultClause",
5903
+ block: clause.block,
5904
+ children: ["default: ", clause.block]
5905
+ };
5906
+ }
5907
+ });
5908
+ if (!defaultClause) {
5909
+ const expressions = [[
5910
+ "",
5911
+ {
5912
+ type: "ThrowStatement",
5913
+ children: ["throw", " ", ref]
5914
+ }
5915
+ ]];
5916
+ const block2 = {
5917
+ type: "BlockStatement",
5918
+ expressions,
5919
+ children: [" {", expressions, "}"],
5920
+ bare: false
5921
+ };
5922
+ clauses.push({
5923
+ type: "DefaultClause",
5924
+ block: block2,
5925
+ children: ["default: ", block2]
5926
+ });
5927
+ }
5928
+ const caseBlock = {
5929
+ type: "CaseBlock",
5930
+ clauses,
5931
+ children: [" {", clauses, "}"]
5932
+ };
5933
+ const patternSwitch = {
5934
+ type: "SwitchStatement",
5935
+ condition,
5936
+ caseBlock,
5937
+ children: ["switch", condition, caseBlock]
5938
+ };
5939
+ const block = {
5940
+ type: "BlockStatement",
5941
+ bare: false,
5942
+ expressions: [["", patternSwitch]],
5943
+ children: [" {", patternSwitch, "}"]
5944
+ };
5945
+ c = makeNode({
5946
+ type: "CatchClause",
5947
+ children: [
5948
+ cs[0].children[0],
5949
+ // whitespace
5950
+ cs[0].children[1],
5951
+ // catch token
5952
+ binding,
5953
+ block
5954
+ ],
5955
+ binding,
5956
+ block
5957
+ });
5958
+ } else {
5959
+ c = cs[0];
5960
+ if (cs.length > 1) {
5961
+ c = append(c, {
5962
+ type: "Error",
5963
+ message: "Only one catch clause allowed unless using pattern matching"
5964
+ });
5965
+ }
5966
+ }
5805
5967
  if (!c && (e || !f)) {
5806
5968
  const emptyCatchBlock = makeEmptyBlock();
5807
5969
  c = {
@@ -5900,8 +6062,9 @@ function processCallMemberExpression(node) {
5900
6062
  }
5901
6063
  }
5902
6064
  }
5903
- for (let i = 0; i < children.length; i++) {
5904
- const glob = children[i];
6065
+ for (let i3 = 0, len22 = children.length; i3 < len22; i3++) {
6066
+ const i = i3;
6067
+ const glob = children[i3];
5905
6068
  if (glob?.type === "PropertyGlob") {
5906
6069
  let prefix = children.slice(0, i);
5907
6070
  const parts = [];
@@ -5972,14 +6135,14 @@ function processCallMemberExpression(node) {
5972
6135
  });
5973
6136
  }
5974
6137
  }
5975
- let ref1;
6138
+ let ref2;
5976
6139
  let object = {
5977
6140
  type: "ObjectExpression",
5978
6141
  children: [
5979
6142
  glob.object.children[0],
5980
6143
  // {
5981
6144
  ...parts,
5982
- (ref1 = glob.object.children)[ref1.length - 1]
6145
+ (ref2 = glob.object.children)[ref2.length - 1]
5983
6146
  // whitespace and }
5984
6147
  ],
5985
6148
  properties: parts,
@@ -6021,6 +6184,33 @@ function processCallMemberExpression(node) {
6021
6184
  ...children.slice(i + 1)
6022
6185
  ]
6023
6186
  });
6187
+ } else if (typeof glob === "object" && glob != null && "type" in glob && glob.type === "SliceExpression" && "reversed" in glob && glob.reversed === true) {
6188
+ const args = [
6189
+ { ...node, children: node.children.slice(0, i) },
6190
+ { ...glob.children[0], token: ", " },
6191
+ ...glob.children.slice(1, -1)
6192
+ ];
6193
+ let ref3;
6194
+ return makeNode({
6195
+ ...node,
6196
+ children: [
6197
+ {
6198
+ type: "CallExpression",
6199
+ children: [
6200
+ getHelperRef("rslice"),
6201
+ makeNode({
6202
+ type: "Call",
6203
+ args,
6204
+ children: [
6205
+ "(",
6206
+ args,
6207
+ (ref3 = glob.children)[ref3.length - 1]
6208
+ ]
6209
+ })
6210
+ ]
6211
+ }
6212
+ ]
6213
+ });
6024
6214
  }
6025
6215
  }
6026
6216
  return node;
@@ -6031,9 +6221,9 @@ function replaceNode(node, newNode, parent) {
6031
6221
  throw new Error("replaceNode failed: node has no parent");
6032
6222
  }
6033
6223
  function recurse(children) {
6034
- for (let i3 = 0, len22 = children.length; i3 < len22; i3++) {
6035
- const i = i3;
6036
- const child = children[i3];
6224
+ for (let i4 = 0, len3 = children.length; i4 < len3; i4++) {
6225
+ const i = i4;
6226
+ const child = children[i4];
6037
6227
  if (child === node) {
6038
6228
  children[i] = newNode;
6039
6229
  return true;
@@ -6125,8 +6315,8 @@ function convertNamedImportsToObject(node, pattern) {
6125
6315
  return { type: "Error", message: "cannot use `type` in dynamic import" };
6126
6316
  } else {
6127
6317
  const { source, binding } = specifier;
6128
- let ref2;
6129
- const delim = (ref2 = specifier.children)[ref2.length - 1];
6318
+ let ref4;
6319
+ const delim = (ref4 = specifier.children)[ref4.length - 1];
6130
6320
  return {
6131
6321
  type: pattern ? "BindingProperty" : "Property",
6132
6322
  name: source,
@@ -6136,7 +6326,7 @@ function convertNamedImportsToObject(node, pattern) {
6136
6326
  };
6137
6327
  }
6138
6328
  });
6139
- let ref3;
6329
+ let ref5;
6140
6330
  return {
6141
6331
  type: pattern ? "ObjectBindingPattern" : "ObjectExpression",
6142
6332
  names: node.names,
@@ -6145,7 +6335,7 @@ function convertNamedImportsToObject(node, pattern) {
6145
6335
  node.children[0],
6146
6336
  // {
6147
6337
  properties,
6148
- (ref3 = node.children)[ref3.length - 1]
6338
+ (ref5 = node.children)[ref5.length - 1]
6149
6339
  // }
6150
6340
  ]
6151
6341
  };
@@ -6251,8 +6441,8 @@ function processAssignments(statements) {
6251
6441
  while (expr.type === "ParenthesizedExpression") {
6252
6442
  expr = expr.expression;
6253
6443
  }
6254
- let m;
6255
- if (m = expr.type, m === "AssignmentExpression" || m === "UpdateExpression") {
6444
+ let m1;
6445
+ if (m1 = expr.type, m1 === "AssignmentExpression" || m1 === "UpdateExpression") {
6256
6446
  if (expr.type === "UpdateExpression" && expr.children[0] === expr.assigned) {
6257
6447
  pre.push("(");
6258
6448
  post.push([", ", lhs, ")"]);
@@ -6266,15 +6456,15 @@ function processAssignments(statements) {
6266
6456
  return;
6267
6457
  }
6268
6458
  const pre = [], post = [];
6269
- let ref4;
6459
+ let ref6;
6270
6460
  switch (exp.type) {
6271
6461
  case "AssignmentExpression": {
6272
6462
  if (!exp.lhs)
6273
6463
  return;
6274
6464
  exp.lhs.forEach((lhsPart, i) => {
6275
- let ref5;
6276
- if (ref5 = extractAssignment(lhsPart[1])) {
6277
- const newLhs = ref5;
6465
+ let ref7;
6466
+ if (ref7 = extractAssignment(lhsPart[1])) {
6467
+ const newLhs = ref7;
6278
6468
  return lhsPart[1] = newLhs;
6279
6469
  }
6280
6470
  ;
@@ -6283,8 +6473,8 @@ function processAssignments(statements) {
6283
6473
  break;
6284
6474
  }
6285
6475
  case "UpdateExpression": {
6286
- if (ref4 = extractAssignment(exp.assigned)) {
6287
- const newLhs = ref4;
6476
+ if (ref6 = extractAssignment(exp.assigned)) {
6477
+ const newLhs = ref6;
6288
6478
  const i = exp.children.indexOf(exp.assigned);
6289
6479
  exp.assigned = exp.children[i] = newLhs;
6290
6480
  }
@@ -6300,7 +6490,7 @@ function processAssignments(statements) {
6300
6490
  const { assigned } = exp;
6301
6491
  const ref = makeRef();
6302
6492
  const newMemberExp = unchainOptionalMemberExpression(assigned, ref, (children) => {
6303
- return exp.children.map(($) => $ === assigned ? children : $);
6493
+ return exp.children.map(($3) => $3 === assigned ? children : $3);
6304
6494
  });
6305
6495
  if (newMemberExp !== assigned) {
6306
6496
  if (newMemberExp.usesRef) {
@@ -6324,23 +6514,23 @@ function processAssignments(statements) {
6324
6514
  (exp) => {
6325
6515
  let { lhs: $1, expression: $2 } = exp, tail = [], len3 = $1.length;
6326
6516
  let block;
6327
- let ref6;
6328
- if (exp.parent?.type === "BlockStatement" && !(ref6 = $1[$1.length - 1])?.[ref6.length - 1]?.special) {
6517
+ let ref8;
6518
+ if (exp.parent?.type === "BlockStatement" && !(ref8 = $1[$1.length - 1])?.[ref8.length - 1]?.special) {
6329
6519
  block = makeBlockFragment();
6330
- let ref7;
6331
- if (ref7 = prependStatementExpressionBlock(
6520
+ let ref9;
6521
+ if (ref9 = prependStatementExpressionBlock(
6332
6522
  { type: "Initializer", expression: $2, children: [void 0, void 0, $2] },
6333
6523
  block
6334
6524
  )) {
6335
- const ref = ref7;
6336
- exp.children = exp.children.map(($3) => $3 === $2 ? ref : $3);
6525
+ const ref = ref9;
6526
+ exp.children = exp.children.map(($4) => $4 === $2 ? ref : $4);
6337
6527
  $2 = ref;
6338
6528
  } else {
6339
6529
  block = void 0;
6340
6530
  }
6341
6531
  }
6342
- let ref8;
6343
- if ($1.some(($4) => (ref8 = $4)[ref8.length - 1].special)) {
6532
+ let ref10;
6533
+ if ($1.some(($5) => (ref10 = $5)[ref10.length - 1].special)) {
6344
6534
  if ($1.length !== 1)
6345
6535
  throw new Error("Only one assignment with id= is allowed");
6346
6536
  const [, lhs, , op] = $1[0];
@@ -6365,8 +6555,8 @@ function processAssignments(statements) {
6365
6555
  if (!(op.token === "=")) {
6366
6556
  continue;
6367
6557
  }
6368
- let m1;
6369
- if (m1 = lhs.type, m1 === "ObjectExpression" || m1 === "ObjectBindingPattern") {
6558
+ let m2;
6559
+ if (m2 = lhs.type, m2 === "ObjectExpression" || m2 === "ObjectBindingPattern") {
6370
6560
  if (!wrapped) {
6371
6561
  wrapped = true;
6372
6562
  lhs.children.splice(0, 0, "(");
@@ -6380,10 +6570,17 @@ function processAssignments(statements) {
6380
6570
  const lastAssignment = $1[i];
6381
6571
  if (lastAssignment[3].token === "=") {
6382
6572
  const lhs = lastAssignment[1];
6383
- let m2;
6573
+ let m3;
6384
6574
  if (lhs.type === "MemberExpression") {
6385
6575
  const members = lhs.children;
6386
6576
  const lastMember = members[members.length - 1];
6577
+ if (typeof lastMember === "object" && lastMember != null && "type" in lastMember && lastMember.type === "CallExpression" && "children" in lastMember && Array.isArray(lastMember.children) && lastMember.children.length >= 1 && lastMember.children[0] === peekHelperRef("rslice")) {
6578
+ lastMember.children.push({
6579
+ type: "Error",
6580
+ message: "Slice range cannot be decreasing in assignment"
6581
+ });
6582
+ break;
6583
+ }
6387
6584
  if (lastMember.type === "SliceExpression") {
6388
6585
  const { start, end, children: c } = lastMember;
6389
6586
  c[0].token = ".splice(";
@@ -6406,9 +6603,9 @@ function processAssignments(statements) {
6406
6603
  exp.names = [];
6407
6604
  break;
6408
6605
  }
6409
- } else if (m2 = lhs.type, m2 === "ObjectBindingPattern" || m2 === "ArrayBindingPattern") {
6606
+ } else if (m3 = lhs.type, m3 === "ObjectBindingPattern" || m3 === "ArrayBindingPattern") {
6410
6607
  processBindingPatternLHS(lhs, tail);
6411
- gatherRecursiveAll(lhs, ($5) => $5.type === "Ref").forEach(refsToDeclare.add.bind(refsToDeclare));
6608
+ gatherRecursiveAll(lhs, ($6) => $6.type === "Ref").forEach(refsToDeclare.add.bind(refsToDeclare));
6412
6609
  }
6413
6610
  }
6414
6611
  i--;
@@ -6441,7 +6638,7 @@ function processAssignments(statements) {
6441
6638
  }
6442
6639
  if (refsToDeclare.size) {
6443
6640
  if (exp.hoistDec) {
6444
- exp.hoistDec.children.push([...refsToDeclare].map(($6) => [",", $6]));
6641
+ exp.hoistDec.children.push([...refsToDeclare].map(($7) => [",", $7]));
6445
6642
  } else {
6446
6643
  exp.hoistDec = {
6447
6644
  type: "Declaration",
@@ -6515,9 +6712,9 @@ function unchainOptionalMemberExpression(exp, ref, innerExp) {
6515
6712
  }
6516
6713
  j++;
6517
6714
  }
6518
- let ref9;
6519
- if (ref9 = conditions.length) {
6520
- const l = ref9;
6715
+ let ref11;
6716
+ if (ref11 = conditions.length) {
6717
+ const l = ref11;
6521
6718
  const cs = flatJoin(conditions, " && ");
6522
6719
  return {
6523
6720
  ...exp,
@@ -6556,27 +6753,27 @@ function processTypes(node) {
6556
6753
  if (!unary.suffix.length) {
6557
6754
  return;
6558
6755
  }
6559
- let ref10;
6560
- let m3;
6561
- if (m3 = (ref10 = unary.suffix)[ref10.length - 1], typeof m3 === "object" && m3 != null && "token" in m3 && m3.token === "?") {
6562
- const { token } = m3;
6756
+ let ref12;
6757
+ let m4;
6758
+ if (m4 = (ref12 = unary.suffix)[ref12.length - 1], typeof m4 === "object" && m4 != null && "token" in m4 && m4.token === "?") {
6759
+ const { token } = m4;
6563
6760
  let last;
6564
6761
  let count = 0;
6565
- let ref11;
6566
- while (unary.suffix.length && (ref11 = unary.suffix)[ref11.length - 1]?.token === "?") {
6762
+ let ref13;
6763
+ while (unary.suffix.length && (ref13 = unary.suffix)[ref13.length - 1]?.token === "?") {
6567
6764
  last = unary.suffix.pop();
6568
6765
  count++;
6569
6766
  }
6570
- let ref12;
6571
- while (unary.suffix.length && (ref12 = unary.suffix)[ref12.length - 1]?.type === "NonNullAssertion") {
6767
+ let ref14;
6768
+ while (unary.suffix.length && (ref14 = unary.suffix)[ref14.length - 1]?.type === "NonNullAssertion") {
6572
6769
  unary.suffix.pop();
6573
6770
  }
6574
- let ref13;
6771
+ let ref15;
6575
6772
  if (unary.suffix.length || unary.prefix.length)
6576
- ref13 = unary;
6773
+ ref15 = unary;
6577
6774
  else
6578
- ref13 = unary.t;
6579
- const t = ref13;
6775
+ ref15 = unary.t;
6776
+ const t = ref15;
6580
6777
  if (unary.parent?.type === "TypeTuple") {
6581
6778
  if (count === 1) {
6582
6779
  unary.suffix.push(last);
@@ -6602,14 +6799,14 @@ function processTypes(node) {
6602
6799
  ]
6603
6800
  });
6604
6801
  }
6605
- } else if (typeof m3 === "object" && m3 != null && "type" in m3 && m3.type === "NonNullAssertion") {
6606
- const { type } = m3;
6607
- let ref14;
6608
- while (unary.suffix.length && (ref14 = unary.suffix)[ref14.length - 1]?.type === "NonNullAssertion") {
6802
+ } else if (typeof m4 === "object" && m4 != null && "type" in m4 && m4.type === "NonNullAssertion") {
6803
+ const { type } = m4;
6804
+ let ref16;
6805
+ while (unary.suffix.length && (ref16 = unary.suffix)[ref16.length - 1]?.type === "NonNullAssertion") {
6609
6806
  unary.suffix.pop();
6610
6807
  }
6611
- let ref15;
6612
- while (unary.suffix.length && (ref15 = unary.suffix)[ref15.length - 1]?.token === "?") {
6808
+ let ref17;
6809
+ while (unary.suffix.length && (ref17 = unary.suffix)[ref17.length - 1]?.token === "?") {
6613
6810
  unary.suffix.pop();
6614
6811
  }
6615
6812
  const t = trimFirstSpace(
@@ -6635,14 +6832,14 @@ function processTypes(node) {
6635
6832
  });
6636
6833
  }
6637
6834
  function processStatementExpressions(statements) {
6638
- gatherRecursiveAll(statements, ($7) => $7.type === "StatementExpression").forEach((_exp) => {
6835
+ gatherRecursiveAll(statements, ($8) => $8.type === "StatementExpression").forEach((_exp) => {
6639
6836
  const exp = _exp;
6640
6837
  const { statement } = exp;
6641
- let ref16;
6838
+ let ref18;
6642
6839
  switch (statement.type) {
6643
6840
  case "IfStatement": {
6644
- if (ref16 = expressionizeIfStatement(statement)) {
6645
- const expression = ref16;
6841
+ if (ref18 = expressionizeIfStatement(statement)) {
6842
+ const expression = ref18;
6646
6843
  return replaceNode(statement, expression, exp);
6647
6844
  } else {
6648
6845
  return replaceNode(statement, wrapIIFE([["", statement]]), exp);
@@ -6711,7 +6908,7 @@ function processProgram(root) {
6711
6908
  if (config2.iife || config2.repl) {
6712
6909
  rootIIFE = wrapIIFE(root.expressions, root.topLevelAwait);
6713
6910
  const newExpressions = [["", rootIIFE]];
6714
- root.children = root.children.map(($8) => $8 === root.expressions ? newExpressions : $8);
6911
+ root.children = root.children.map(($9) => $9 === root.expressions ? newExpressions : $9);
6715
6912
  root.expressions = newExpressions;
6716
6913
  }
6717
6914
  addParentPointers(root);
@@ -6751,17 +6948,17 @@ async function processProgramAsync(root) {
6751
6948
  await processComptime(statements);
6752
6949
  }
6753
6950
  function processRepl(root, rootIIFE) {
6754
- const topBlock = gatherRecursive(rootIIFE, ($9) => $9.type === "BlockStatement")[0];
6951
+ const topBlock = gatherRecursive(rootIIFE, ($10) => $10.type === "BlockStatement")[0];
6755
6952
  let i = 0;
6756
- for (let ref17 = gatherRecursiveWithinFunction(topBlock, ($10) => $10.type === "Declaration"), i4 = 0, len3 = ref17.length; i4 < len3; i4++) {
6757
- const decl = ref17[i4];
6953
+ for (let ref19 = gatherRecursiveWithinFunction(topBlock, ($11) => $11.type === "Declaration"), i5 = 0, len4 = ref19.length; i5 < len4; i5++) {
6954
+ const decl = ref19[i5];
6758
6955
  if (decl.parent === topBlock || decl.decl === "var") {
6759
6956
  decl.children.shift();
6760
6957
  root.expressions.splice(i++, 0, ["", `var ${decl.names.join(",")};`]);
6761
6958
  }
6762
6959
  }
6763
- for (let ref18 = gatherRecursive(topBlock, ($11) => $11.type === "FunctionExpression"), i5 = 0, len4 = ref18.length; i5 < len4; i5++) {
6764
- const func = ref18[i5];
6960
+ for (let ref20 = gatherRecursive(topBlock, ($12) => $12.type === "FunctionExpression"), i6 = 0, len5 = ref20.length; i6 < len5; i6++) {
6961
+ const func = ref20[i6];
6765
6962
  if (func.name && func.parent?.type === "BlockStatement") {
6766
6963
  if (func.parent === topBlock) {
6767
6964
  replaceNode(func, void 0);
@@ -6773,17 +6970,17 @@ function processRepl(root, rootIIFE) {
6773
6970
  }
6774
6971
  }
6775
6972
  }
6776
- for (let ref19 = gatherRecursiveWithinFunction(topBlock, ($12) => $12.type === "ClassExpression"), i6 = 0, len5 = ref19.length; i6 < len5; i6++) {
6777
- const classExp = ref19[i6];
6778
- let m4;
6779
- if (classExp.name && classExp.parent === topBlock || (m4 = classExp.parent, typeof m4 === "object" && m4 != null && "type" in m4 && m4.type === "ReturnStatement" && "parent" in m4 && m4.parent === topBlock)) {
6973
+ for (let ref21 = gatherRecursiveWithinFunction(topBlock, ($13) => $13.type === "ClassExpression"), i7 = 0, len6 = ref21.length; i7 < len6; i7++) {
6974
+ const classExp = ref21[i7];
6975
+ let m5;
6976
+ if (classExp.name && classExp.parent === topBlock || (m5 = classExp.parent, typeof m5 === "object" && m5 != null && "type" in m5 && m5.type === "ReturnStatement" && "parent" in m5 && m5.parent === topBlock)) {
6780
6977
  classExp.children.unshift(classExp.name, "=");
6781
6978
  root.expressions.splice(i++, 0, ["", `var ${classExp.name};`]);
6782
6979
  }
6783
6980
  }
6784
6981
  }
6785
6982
  function populateRefs(statements) {
6786
- const refNodes = gatherRecursive(statements, ($13) => $13.type === "Ref");
6983
+ const refNodes = gatherRecursive(statements, ($14) => $14.type === "Ref");
6787
6984
  if (refNodes.length) {
6788
6985
  const ids = gatherRecursive(statements, (s) => s.type === "Identifier");
6789
6986
  const names = new Set(ids.flatMap(({ names: names2 }) => names2 || []));
@@ -6806,11 +7003,11 @@ function populateRefs(statements) {
6806
7003
  function processPlaceholders(statements) {
6807
7004
  const placeholderMap = /* @__PURE__ */ new Map();
6808
7005
  const liftedIfs = /* @__PURE__ */ new Set();
6809
- gatherRecursiveAll(statements, ($14) => $14.type === "Placeholder").forEach((_exp) => {
7006
+ gatherRecursiveAll(statements, ($15) => $15.type === "Placeholder").forEach((_exp) => {
6810
7007
  const exp = _exp;
6811
7008
  let ancestor;
6812
7009
  if (exp.subtype === ".") {
6813
- ({ ancestor } = findAncestor(exp, ($15) => $15.type === "Call"));
7010
+ ({ ancestor } = findAncestor(exp, ($16) => $16.type === "Call"));
6814
7011
  ancestor = ancestor?.parent;
6815
7012
  while (ancestor?.parent?.type === "UnaryExpression" || ancestor?.parent?.type === "NewExpression") {
6816
7013
  ancestor = ancestor.parent;
@@ -6829,10 +7026,10 @@ function processPlaceholders(statements) {
6829
7026
  if (type === "IfStatement") {
6830
7027
  liftedIfs.add(ancestor2);
6831
7028
  }
6832
- let m5;
6833
7029
  let m6;
7030
+ let m7;
6834
7031
  return type === "Call" || // Block, except for if/else blocks when condition already lifted
6835
- type === "BlockStatement" && !((m5 = ancestor2.parent, typeof m5 === "object" && m5 != null && "type" in m5 && m5.type === "IfStatement") && liftedIfs.has(ancestor2.parent)) && !((m6 = ancestor2.parent, typeof m6 === "object" && m6 != null && "type" in m6 && m6.type === "ElseClause" && "parent" in m6 && typeof m6.parent === "object" && m6.parent != null && "type" in m6.parent && m6.parent.type === "IfStatement") && liftedIfs.has(ancestor2.parent.parent)) || type === "PipelineExpression" || // Declaration
7032
+ type === "BlockStatement" && !((m6 = ancestor2.parent, typeof m6 === "object" && m6 != null && "type" in m6 && m6.type === "IfStatement") && liftedIfs.has(ancestor2.parent)) && !((m7 = ancestor2.parent, typeof m7 === "object" && m7 != null && "type" in m7 && m7.type === "ElseClause" && "parent" in m7 && typeof m7.parent === "object" && m7.parent != null && "type" in m7.parent && m7.parent.type === "IfStatement") && liftedIfs.has(ancestor2.parent.parent)) || type === "PipelineExpression" || // Declaration
6836
7033
  type === "Initializer" || // Right-hand side of assignment
6837
7034
  type === "AssignmentExpression" && findChildIndex(ancestor2, child2) === ancestor2.children.indexOf(ancestor2.expression) || type === "ReturnStatement" || type === "YieldExpression";
6838
7035
  }));
@@ -6908,11 +7105,11 @@ function processPlaceholders(statements) {
6908
7105
  for (const [ancestor, placeholders] of placeholderMap) {
6909
7106
  let ref = makeRef("$");
6910
7107
  let typeSuffix;
6911
- for (let i7 = 0, len6 = placeholders.length; i7 < len6; i7++) {
6912
- const placeholder = placeholders[i7];
7108
+ for (let i8 = 0, len7 = placeholders.length; i8 < len7; i8++) {
7109
+ const placeholder = placeholders[i8];
6913
7110
  typeSuffix ??= placeholder.typeSuffix;
6914
- let ref20;
6915
- replaceNode((ref20 = placeholder.children)[ref20.length - 1], ref);
7111
+ let ref22;
7112
+ replaceNode((ref22 = placeholder.children)[ref22.length - 1], ref);
6916
7113
  }
6917
7114
  const { parent } = ancestor;
6918
7115
  const body = maybeUnwrap(ancestor);
@@ -6933,16 +7130,16 @@ function processPlaceholders(statements) {
6933
7130
  }
6934
7131
  case "PipelineExpression": {
6935
7132
  const i = findChildIndex(parent, ancestor);
6936
- let ref21;
7133
+ let ref23;
6937
7134
  if (i === 1) {
6938
- ref21 = ancestor === parent.children[i];
7135
+ ref23 = ancestor === parent.children[i];
6939
7136
  } else if (i === 2) {
6940
- ref21 = ancestor === parent.children[i][findChildIndex(parent.children[i], ancestor)][3];
7137
+ ref23 = ancestor === parent.children[i][findChildIndex(parent.children[i], ancestor)][3];
6941
7138
  } else {
6942
- ref21 = void 0;
7139
+ ref23 = void 0;
6943
7140
  }
6944
7141
  ;
6945
- outer = ref21;
7142
+ outer = ref23;
6946
7143
  break;
6947
7144
  }
6948
7145
  case "AssignmentExpression":
@@ -6957,9 +7154,9 @@ function processPlaceholders(statements) {
6957
7154
  fnExp = makeLeftHandSideExpression(fnExp);
6958
7155
  }
6959
7156
  replaceNode(ancestor, fnExp, parent);
6960
- let ref22;
6961
- if (ref22 = getTrimmingSpace(body)) {
6962
- const ws = ref22;
7157
+ let ref24;
7158
+ if (ref24 = getTrimmingSpace(body)) {
7159
+ const ws = ref24;
6963
7160
  inplaceInsertTrimmingSpace(body, "");
6964
7161
  inplacePrepend(ws, fnExp);
6965
7162
  }
@@ -7004,8 +7201,8 @@ function reorderBindingRestProperty(props) {
7004
7201
  }
7005
7202
  ];
7006
7203
  }
7007
- let ref23;
7008
- if (Array.isArray(rest.delim) && (ref23 = rest.delim)[ref23.length - 1]?.token === ",") {
7204
+ let ref25;
7205
+ if (Array.isArray(rest.delim) && (ref25 = rest.delim)[ref25.length - 1]?.token === ",") {
7009
7206
  rest.delim = rest.delim.slice(0, -1);
7010
7207
  rest.children = [...rest.children.slice(0, -1), rest.delim];
7011
7208
  }
@@ -7030,9 +7227,9 @@ function replaceNodes(root, predicate, replacer) {
7030
7227
  return root;
7031
7228
  }
7032
7229
  }
7033
- for (let i8 = 0, len7 = array.length; i8 < len7; i8++) {
7034
- const i = i8;
7035
- const node = array[i8];
7230
+ for (let i9 = 0, len8 = array.length; i9 < len8; i9++) {
7231
+ const i = i9;
7232
+ const node = array[i9];
7036
7233
  if (!(node != null)) {
7037
7234
  return;
7038
7235
  }
@@ -7056,9 +7253,9 @@ function replaceNodesRecursive(root, predicate, replacer) {
7056
7253
  return root;
7057
7254
  }
7058
7255
  }
7059
- for (let i9 = 0, len8 = array.length; i9 < len8; i9++) {
7060
- const i = i9;
7061
- const node = array[i9];
7256
+ for (let i10 = 0, len9 = array.length; i10 < len9; i10++) {
7257
+ const i = i10;
7258
+ const node = array[i10];
7062
7259
  if (!(node != null)) {
7063
7260
  continue;
7064
7261
  }
@@ -7476,7 +7673,7 @@ var grammar = {
7476
7673
  IgnoreColon,
7477
7674
  TryStatement,
7478
7675
  CatchClause,
7479
- CatchBind,
7676
+ CatchBinding,
7480
7677
  FinallyClause,
7481
7678
  CatchParameter,
7482
7679
  Condition,
@@ -7820,6 +8017,7 @@ var grammar = {
7820
8017
  TypeSuffix,
7821
8018
  MaybeNestedType,
7822
8019
  MaybeNestedTypePrimary,
8020
+ MaybeNestedTypeUnary,
7823
8021
  ReturnTypeSuffix,
7824
8022
  ReturnType,
7825
8023
  TypePredicate,
@@ -9878,11 +10076,12 @@ var MemberBracketContent$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(OpenBracke
9878
10076
  var ws = $3;
9879
10077
  var close = $4;
9880
10078
  if (expression.type === "SliceParameters") {
9881
- const { start, end, children } = expression;
10079
+ const { start, end, reversed, children } = expression;
9882
10080
  return {
9883
10081
  type: "SliceExpression",
9884
10082
  start,
9885
10083
  end,
10084
+ reversed,
9886
10085
  children: [
9887
10086
  { ...open, token: ".slice(" },
9888
10087
  ...children,
@@ -9899,78 +10098,57 @@ var MemberBracketContent$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(OpenBracke
9899
10098
  function MemberBracketContent(ctx, state2) {
9900
10099
  return (0, import_lib4.$EVENT)(ctx, state2, "MemberBracketContent", MemberBracketContent$0);
9901
10100
  }
9902
- var SliceParameters$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(Expression, __, RangeDots, (0, import_lib4.$E)(Expression)), function($skip, $loc, $0, $1, $2, $3, $4) {
9903
- var start = $1;
9904
- var ws = $2;
9905
- var dots = $3;
9906
- var end = $4;
10101
+ var SliceParameters$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(Loc, (0, import_lib4.$E)(Expression), __, RangeDots, Loc, (0, import_lib4.$E)(Expression)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
10102
+ var ls = $1;
10103
+ var start = $2;
10104
+ var ws = $3;
10105
+ var dots = $4;
10106
+ var le = $5;
10107
+ var end = $6;
10108
+ const reversed = dots.increasing === false;
10109
+ const sign = reversed ? "-" : "+";
9907
10110
  let children;
10111
+ start ??= {
10112
+ $loc: ls.$loc,
10113
+ token: reversed ? "-1" : "0"
10114
+ };
10115
+ if (!end) {
10116
+ if (reversed) {
10117
+ end = {
10118
+ $loc: le.$loc,
10119
+ token: "0"
10120
+ };
10121
+ } else if (!dots.right.inclusive && !dots.triple) {
10122
+ end = {
10123
+ $loc: le.$loc,
10124
+ token: "-1"
10125
+ };
10126
+ }
10127
+ }
9908
10128
  if (!dots.left.inclusive) {
9909
- start = ["1 + ", makeLeftHandSideExpression(start)];
10129
+ start = [makeLeftHandSideExpression(start), ` ${sign} 1`];
9910
10130
  }
9911
10131
  if (end) {
9912
10132
  const inc = [];
9913
10133
  if (dots.right.inclusive) {
9914
- end = ["1 + ", makeLeftHandSideExpression(end)];
9915
- inc.push(" || 1/0");
10134
+ end = [makeLeftHandSideExpression(end), ` ${sign} 1`];
10135
+ if (!reversed)
10136
+ inc.push(" || 1/0");
9916
10137
  }
9917
10138
  children = [start, [...ws, dots.children[0], { token: ", ", $loc: dots.$loc }], [dots.children[1], end, ...inc]];
9918
10139
  } else {
9919
10140
  children = [start, ws];
9920
10141
  }
9921
- if (dots.increasing === false) {
9922
- children.push({
9923
- type: "Error",
9924
- message: "Slice range cannot be decreasing",
9925
- $loc: dots.$loc
9926
- });
9927
- }
9928
10142
  return {
9929
10143
  type: "SliceParameters",
9930
10144
  start,
9931
10145
  end,
10146
+ reversed,
9932
10147
  children
9933
10148
  };
9934
10149
  });
9935
- var SliceParameters$1 = (0, import_lib4.$TS)((0, import_lib4.$S)(Loc, __, (0, import_lib4.$C)(DotDotDot, DotDot), Expression), function($skip, $loc, $0, $1, $2, $3, $4) {
9936
- var l = $1;
9937
- var ws = $2;
9938
- var sep = $3;
9939
- var end = $4;
9940
- const inclusive = sep.token === "..";
9941
- const inc = [];
9942
- if (inclusive) {
9943
- end = ["1 + ", end];
9944
- inc.push(" || 1/0");
9945
- }
9946
- const start = {
9947
- $loc: l.$loc,
9948
- token: "0"
9949
- };
9950
- return {
9951
- type: "SliceParameters",
9952
- start,
9953
- end,
9954
- children: [start, [...ws, { ...sep, token: ", " }], [end, ...inc]]
9955
- };
9956
- });
9957
- var SliceParameters$2 = (0, import_lib4.$TS)((0, import_lib4.$S)(Loc, __, (0, import_lib4.$C)(DotDot, DotDotDot), (0, import_lib4.$Y)((0, import_lib4.$S)(__, CloseBracket))), function($skip, $loc, $0, $1, $2, $3, $4) {
9958
- var l = $1;
9959
- var ws = $2;
9960
- const start = {
9961
- $loc: l.$loc,
9962
- token: "0"
9963
- };
9964
- return {
9965
- type: "SliceParameters",
9966
- start,
9967
- end: void 0,
9968
- children: [start, ws]
9969
- };
9970
- });
9971
- var SliceParameters$$ = [SliceParameters$0, SliceParameters$1, SliceParameters$2];
9972
10150
  function SliceParameters(ctx, state2) {
9973
- return (0, import_lib4.$EVENT_C)(ctx, state2, "SliceParameters", SliceParameters$$);
10151
+ return (0, import_lib4.$EVENT)(ctx, state2, "SliceParameters", SliceParameters$0);
9974
10152
  }
9975
10153
  var AccessStart$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$E)(PropertyAccessModifier), Dot, (0, import_lib4.$N)((0, import_lib4.$EXPECT)($R11, "AccessStart /[.\\s]/"))), function($skip, $loc, $0, $1, $2, $3) {
9976
10154
  var modifier = $1;
@@ -11639,6 +11817,7 @@ var RangeDots$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(DotDotDot), function(
11639
11817
  left: { inclusive: true, raw: "" },
11640
11818
  right: { inclusive: false, raw: "." },
11641
11819
  increasing: void 0,
11820
+ triple: true,
11642
11821
  children: []
11643
11822
  };
11644
11823
  });
@@ -13916,12 +14095,14 @@ var CaseClause$3 = (0, import_lib4.$TS)((0, import_lib4.$S)(Default, ImpliedColo
13916
14095
  };
13917
14096
  });
13918
14097
  var CaseClause$4 = (0, import_lib4.$TS)((0, import_lib4.$S)(Else, ImpliedColon, (0, import_lib4.$C)(ThenClause, BracedBlock, EmptyBlock)), function($skip, $loc, $0, $1, $2, $3) {
14098
+ var e = $1;
14099
+ var colon = $2;
13919
14100
  var block = $3;
13920
- $1.token = "default";
14101
+ e = { ...e, token: "default" };
13921
14102
  return {
13922
14103
  type: "DefaultClause",
13923
14104
  block,
13924
- children: $0
14105
+ children: [e, colon, block]
13925
14106
  };
13926
14107
  });
13927
14108
  var CaseClause$$ = [CaseClause$0, CaseClause$1, CaseClause$2, CaseClause$3, CaseClause$4];
@@ -13992,36 +14173,56 @@ var IgnoreColon$0 = (0, import_lib4.$TV)((0, import_lib4.$E)((0, import_lib4.$S)
13992
14173
  function IgnoreColon(ctx, state2) {
13993
14174
  return (0, import_lib4.$EVENT)(ctx, state2, "IgnoreColon", IgnoreColon$0);
13994
14175
  }
13995
- var TryStatement$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(Try, (0, import_lib4.$N)((0, import_lib4.$EXPECT)($L16, 'TryStatement ":"')), NoPostfixBracedOrEmptyBlock, (0, import_lib4.$E)(CatchClause), (0, import_lib4.$E)(ElseClause), (0, import_lib4.$E)(FinallyClause)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
14176
+ var TryStatement$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(Try, (0, import_lib4.$N)((0, import_lib4.$EXPECT)($L16, 'TryStatement ":"')), NoPostfixBracedOrEmptyBlock, (0, import_lib4.$Q)(CatchClause), (0, import_lib4.$E)(ElseClause), (0, import_lib4.$E)(FinallyClause)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
13996
14177
  return processTryBlock($0);
13997
14178
  });
13998
14179
  function TryStatement(ctx, state2) {
13999
14180
  return (0, import_lib4.$EVENT)(ctx, state2, "TryStatement", TryStatement$0);
14000
14181
  }
14001
- var CatchClause$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$C)(Nested, _), Catch, (0, import_lib4.$E)(CatchBind), (0, import_lib4.$C)(BracedThenClause, BracedOrEmptyBlock)), function($skip, $loc, $0, $1, $2, $3, $4) {
14182
+ var CatchClause$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$C)(Nested, _), Catch, (0, import_lib4.$E)(CatchBinding), (0, import_lib4.$C)(BracedThenClause, BracedOrEmptyBlock)), function($skip, $loc, $0, $1, $2, $3, $4) {
14183
+ var binding = $3;
14002
14184
  var block = $4;
14003
14185
  return {
14004
14186
  type: "CatchClause",
14005
14187
  children: $0,
14006
- block
14188
+ block,
14189
+ binding
14007
14190
  };
14008
14191
  });
14009
14192
  function CatchClause(ctx, state2) {
14010
14193
  return (0, import_lib4.$EVENT)(ctx, state2, "CatchClause", CatchClause$0);
14011
14194
  }
14012
- var CatchBind$0 = (0, import_lib4.$S)((0, import_lib4.$E)(_), OpenParen, __, CatchParameter, __, CloseParen);
14013
- var CatchBind$1 = (0, import_lib4.$TS)((0, import_lib4.$S)(_, InsertOpenParen, (0, import_lib4.$N)(EOS), ForbidIndentedApplication, (0, import_lib4.$E)(CatchParameter), RestoreIndentedApplication, InsertCloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
14195
+ var CatchBinding$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$E)(_), OpenParen, __, AllowAll, (0, import_lib4.$E)(CatchParameter), RestoreAll, __, CloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
14196
+ var ws1 = $1;
14197
+ var open = $2;
14198
+ var ws2 = $3;
14199
+ var parameter = $5;
14200
+ var ws3 = $7;
14201
+ var close = $8;
14202
+ if (!parameter)
14203
+ return $skip;
14204
+ return {
14205
+ type: "CatchBinding",
14206
+ parameter,
14207
+ children: [ws1, open, ws2, parameter, ws3, close]
14208
+ };
14209
+ });
14210
+ var CatchBinding$1 = (0, import_lib4.$TS)((0, import_lib4.$S)(_, InsertOpenParen, (0, import_lib4.$N)(EOS), ForbidIndentedApplication, (0, import_lib4.$E)(CatchParameter), RestoreIndentedApplication, InsertCloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
14014
14211
  var ws = $1;
14015
14212
  var open = $2;
14016
- var param = $5;
14213
+ var parameter = $5;
14017
14214
  var close = $7;
14018
- if (!param)
14215
+ if (!parameter)
14019
14216
  return $skip;
14020
- return [ws, open, param, close];
14217
+ return {
14218
+ type: "CatchBinding",
14219
+ parameter,
14220
+ children: [ws, open, parameter, close]
14221
+ };
14021
14222
  });
14022
- var CatchBind$$ = [CatchBind$0, CatchBind$1];
14023
- function CatchBind(ctx, state2) {
14024
- return (0, import_lib4.$EVENT_C)(ctx, state2, "CatchBind", CatchBind$$);
14223
+ var CatchBinding$$ = [CatchBinding$0, CatchBinding$1];
14224
+ function CatchBinding(ctx, state2) {
14225
+ return (0, import_lib4.$EVENT_C)(ctx, state2, "CatchBinding", CatchBinding$$);
14025
14226
  }
14026
14227
  var FinallyClause$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$C)(Nested, _), Finally, (0, import_lib4.$C)(BracedThenClause, BracedOrEmptyBlock)), function($skip, $loc, $0, $1, $2, $3) {
14027
14228
  var block = $3;
@@ -14034,9 +14235,34 @@ var FinallyClause$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$
14034
14235
  function FinallyClause(ctx, state2) {
14035
14236
  return (0, import_lib4.$EVENT)(ctx, state2, "FinallyClause", FinallyClause$0);
14036
14237
  }
14037
- var CatchParameter$0 = (0, import_lib4.$S)(BindingIdentifier, (0, import_lib4.$E)(TypeSuffix));
14038
- var CatchParameter$1 = (0, import_lib4.$S)(BindingPattern, (0, import_lib4.$E)(TypeSuffix));
14039
- var CatchParameter$$ = [CatchParameter$0, CatchParameter$1];
14238
+ var CatchParameter$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(BindingIdentifier, (0, import_lib4.$E)(TypeSuffix)), function($skip, $loc, $0, $1, $2) {
14239
+ var binding = $1;
14240
+ var typeSuffix = $2;
14241
+ return {
14242
+ type: "CatchParameter",
14243
+ binding,
14244
+ typeSuffix,
14245
+ children: $0
14246
+ };
14247
+ });
14248
+ var CatchParameter$1 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$C)(ObjectBindingPattern, ArrayBindingPattern), TypeSuffix), function($skip, $loc, $0, $1, $2) {
14249
+ var binding = $1;
14250
+ var typeSuffix = $2;
14251
+ return {
14252
+ type: "CatchParameter",
14253
+ binding,
14254
+ typeSuffix,
14255
+ children: [binding, typeSuffix]
14256
+ };
14257
+ });
14258
+ var CatchParameter$2 = (0, import_lib4.$TS)((0, import_lib4.$S)(PatternExpressionList), function($skip, $loc, $0, $1) {
14259
+ return {
14260
+ type: "CatchPattern",
14261
+ children: $0,
14262
+ patterns: $1
14263
+ };
14264
+ });
14265
+ var CatchParameter$$ = [CatchParameter$0, CatchParameter$1, CatchParameter$2];
14040
14266
  function CatchParameter(ctx, state2) {
14041
14267
  return (0, import_lib4.$EVENT_C)(ctx, state2, "CatchParameter", CatchParameter$$);
14042
14268
  }
@@ -17442,6 +17668,19 @@ var MaybeNestedTypePrimary$$ = [MaybeNestedTypePrimary$0, MaybeNestedTypePrimary
17442
17668
  function MaybeNestedTypePrimary(ctx, state2) {
17443
17669
  return (0, import_lib4.$EVENT_C)(ctx, state2, "MaybeNestedTypePrimary", MaybeNestedTypePrimary$$);
17444
17670
  }
17671
+ var MaybeNestedTypeUnary$0 = NestedTypeBulletedTuple;
17672
+ var MaybeNestedTypeUnary$1 = NestedInterfaceBlock;
17673
+ var MaybeNestedTypeUnary$2 = NestedTypeBinaryChain;
17674
+ var MaybeNestedTypeUnary$3 = (0, import_lib4.$TS)((0, import_lib4.$S)(PushIndent, (0, import_lib4.$E)((0, import_lib4.$S)(Nested, Type)), PopIndent), function($skip, $loc, $0, $1, $2, $3) {
17675
+ if (!$2)
17676
+ return $skip;
17677
+ return $2;
17678
+ });
17679
+ var MaybeNestedTypeUnary$4 = (0, import_lib4.$S)(NotDedented, TypeUnary);
17680
+ var MaybeNestedTypeUnary$$ = [MaybeNestedTypeUnary$0, MaybeNestedTypeUnary$1, MaybeNestedTypeUnary$2, MaybeNestedTypeUnary$3, MaybeNestedTypeUnary$4];
17681
+ function MaybeNestedTypeUnary(ctx, state2) {
17682
+ return (0, import_lib4.$EVENT_C)(ctx, state2, "MaybeNestedTypeUnary", MaybeNestedTypeUnary$$);
17683
+ }
17445
17684
  var ReturnTypeSuffix$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$E)(_), (0, import_lib4.$E)(QuestionMark), (0, import_lib4.$E)(_), Colon, ReturnType), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
17446
17685
  var optional = $2;
17447
17686
  var t = $5;
@@ -17496,7 +17735,7 @@ var Type$0 = TypeWithPostfix;
17496
17735
  function Type(ctx, state2) {
17497
17736
  return (0, import_lib4.$EVENT)(ctx, state2, "Type", Type$0);
17498
17737
  }
17499
- var TypeBinary$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$E)((0, import_lib4.$S)(NotDedented, TypeBinaryOp, __)), TypeUnary, (0, import_lib4.$Q)((0, import_lib4.$S)(NotDedented, TypeBinaryOp, __, TypeUnary))), function($skip, $loc, $0, $1, $2, $3) {
17738
+ var TypeBinary$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$E)((0, import_lib4.$S)(NotDedented, TypeBinaryOp, __)), TypeUnary, (0, import_lib4.$Q)((0, import_lib4.$S)(NotDedented, TypeBinaryOp, MaybeNestedTypeUnary))), function($skip, $loc, $0, $1, $2, $3) {
17500
17739
  var optionalPrefix = $1;
17501
17740
  var t = $2;
17502
17741
  var ops = $3;