@magnusopera/fscript 0.92.3 → 0.92.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.
@@ -1,7 +1,7 @@
1
1
 
2
2
  import { class_type } from "../fable_modules/fable-library-js.5.27.0/Reflection.js";
3
3
  import { item } from "../fable_modules/fable-library-js.5.27.0/Array.js";
4
- import { equals } from "../fable_modules/fable-library-js.5.27.0/Util.js";
4
+ import { compare, safeHash, curry2, equals } from "../fable_modules/fable-library-js.5.27.0/Util.js";
5
5
  import { ParseException, ParseError } from "./Error.js";
6
6
  import { TokenKind } from "./Token.js";
7
7
  import { Span, SpanModule_merge } from "./Span.js";
@@ -9,11 +9,14 @@ import { substring, isNullOrWhiteSpace, concat, join, getCharAtIndex, isNullOrEm
9
9
  import { isUpper } from "../fable_modules/fable-library-js.5.27.0/Char.js";
10
10
  import { Ast_spanOfStmt, Attribute, MapEntry, Ast_spanOfExpr, InterpolatedPart, Expr, Ast_spanOfPattern, Pattern, Stmt, TypeDef, BackendImport, Param, TypeRef, Literal } from "./Ast.js";
11
11
  import { tokenizeArrayWithSourceNameAndOrigin } from "./Lexer.js";
12
+ import { map } from "../fable_modules/fable-library-js.5.27.0/Option.js";
13
+ import { singleton, foldBack, head as head_1, tail as tail_1, isEmpty, empty, ofSeq } from "../fable_modules/fable-library-js.5.27.0/List.js";
12
14
  import { addToSet } from "../fable_modules/fable-library-js.5.27.0/MapUtil.js";
13
- import { foldBack as foldBack_1, toList } from "../fable_modules/fable-library-js.5.27.0/Seq.js";
14
- import { singleton, foldBack, head as head_1, tail as tail_1, isEmpty, empty } from "../fable_modules/fable-library-js.5.27.0/List.js";
15
+ import { map as map_1, foldBack as foldBack_1, toList } from "../fable_modules/fable-library-js.5.27.0/Seq.js";
15
16
  import { StringBuilder__Append_244C7CD6, StringBuilder__Clear, StringBuilder__get_Length, StringBuilder_$ctor } from "../fable_modules/fable-library-js.5.27.0/System.Text.js";
16
17
  import { toString } from "../fable_modules/fable-library-js.5.27.0/Types.js";
18
+ import { Dictionary } from "../fable_modules/fable-library-js.5.27.0/MutableMap.js";
19
+ import { ofSeq as ofSeq_1 } from "../fable_modules/fable-library-js.5.27.0/Map.js";
17
20
 
18
21
  class TokenStream {
19
22
  constructor(tokens) {
@@ -172,9 +175,51 @@ function parseLiteral(t) {
172
175
  }
173
176
  }
174
177
 
175
- function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn, src) {
178
+ function parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, startLine, startColumn, src) {
176
179
  const tokens = tokenizeArrayWithSourceNameAndOrigin(sourceName, startLine, startColumn, src);
177
180
  const stream = TokenStream_$ctor_Z317EFDB2(tokens);
181
+ const fieldLabels = () => {
182
+ const option_1 = captureFieldLabels;
183
+ if (option_1 != null) {
184
+ return (map(curry2, option_1), []);
185
+ }
186
+ else {
187
+ return undefined;
188
+ }
189
+ };
190
+ const addFieldLabel = (labels, token) => {
191
+ const option_3 = labels;
192
+ if (option_3 != null) {
193
+ const items = option_3;
194
+ void (items.push(token));
195
+ }
196
+ };
197
+ const recordFieldLabels = (span, labels_1) => {
198
+ [map(curry2, captureFieldLabels), labels_1];
199
+ let matchResult, capture, items_1;
200
+ if (captureFieldLabels != null) {
201
+ if (labels_1 != null) {
202
+ matchResult = 0;
203
+ capture = map(curry2, captureFieldLabels);
204
+ items_1 = labels_1;
205
+ }
206
+ else {
207
+ matchResult = 1;
208
+ }
209
+ }
210
+ else {
211
+ matchResult = 1;
212
+ }
213
+ switch (matchResult) {
214
+ case 0: {
215
+ capture(span)(ofSeq(items_1));
216
+ break;
217
+ }
218
+ case 1: {
219
+ break;
220
+ }
221
+ }
222
+ };
178
223
  const consumeLayoutSeparators = () => {
179
224
  let consumed = false;
180
225
  let progress = true;
@@ -201,8 +246,8 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
201
246
  let foundSameLine = false;
202
247
  while (keepSearching && (i_2 >= 0)) {
203
248
  const tok = TokenStream__TokenAt_Z524259A4(stream, i_2);
204
- const matchValue_1 = tok.Kind;
205
- switch (matchValue_1.tag) {
249
+ const matchValue_2 = tok.Kind;
250
+ switch (matchValue_2.tag) {
206
251
  case 1: {
207
252
  keepSearching = false;
208
253
  break;
@@ -226,8 +271,8 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
226
271
  let foundSameLine_1 = false;
227
272
  while (keepSearching_1 && (i_3 < tokens.length)) {
228
273
  const tok_1 = TokenStream__TokenAt_Z524259A4(stream, i_3);
229
- const matchValue_2 = tok_1.Kind;
230
- switch (matchValue_2.tag) {
274
+ const matchValue_3 = tok_1.Kind;
275
+ switch (matchValue_3.tag) {
231
276
  case 1:
232
277
  case 2:
233
278
  case 3: {
@@ -245,16 +290,16 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
245
290
  let allowIndentedApplication = true;
246
291
  let allowBinaryNewlineSkipping = true;
247
292
  const parseTypeRefAtom = () => {
248
- let firstName, matchValue_3, parts_1, keepGoing;
293
+ let firstName, matchValue_4, parts_1, keepGoing;
249
294
  TokenStream__SkipNewlines(stream);
250
- const matchValue_5 = TokenStream__Peek(stream).Kind;
251
- switch (matchValue_5.tag) {
295
+ const matchValue_6 = TokenStream__Peek(stream).Kind;
296
+ switch (matchValue_6.tag) {
252
297
  case 4:
253
- return new TypeRef(/* TRName */ 0, [(firstName = ((matchValue_3 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected type name").Kind, (matchValue_3.tag === 4) ? matchValue_3.fields[0] : "")), (parts_1 = [], (void (parts_1.push(firstName)), (keepGoing = true, ((() => {
298
+ return new TypeRef(/* TRName */ 0, [(firstName = ((matchValue_4 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected type name").Kind, (matchValue_4.tag === 4) ? matchValue_4.fields[0] : "")), (parts_1 = [], (void (parts_1.push(firstName)), (keepGoing = true, ((() => {
254
299
  while (keepGoing && TokenStream__Match_5CEB78CD(stream, TokenKind.Dot)) {
255
- const matchValue_4 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'.\' in qualified type name").Kind;
256
- if (matchValue_4.tag === 4) {
257
- void (parts_1.push(matchValue_4.fields[0]));
300
+ const matchValue_5 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'.\' in qualified type name").Kind;
301
+ if (matchValue_5.tag === 4) {
302
+ void (parts_1.push(matchValue_5.fields[0]));
258
303
  }
259
304
  keepGoing = true;
260
305
  }
@@ -267,8 +312,8 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
267
312
  const parseField = () => {
268
313
  const nameTok = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name in inline record type");
269
314
  let fieldName;
270
- const matchValue_6 = nameTok.Kind;
271
- fieldName = ((matchValue_6.tag === 4) ? matchValue_6.fields[0] : "");
315
+ const matchValue_7 = nameTok.Kind;
316
+ fieldName = ((matchValue_7.tag === 4) ? matchValue_7.fields[0] : "");
272
317
  if (!addToSet(fieldName, seen)) {
273
318
  throw new ParseException(new ParseError(concat("Duplicate field \'", fieldName, "\' in inline record type"), nameTok.Span));
274
319
  }
@@ -300,14 +345,14 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
300
345
  TokenStream__Next(stream);
301
346
  const first_1 = parseTypeRef();
302
347
  if (TokenStream__Match_5CEB78CD(stream, TokenKind.Star)) {
303
- const items = [];
304
- void (items.push(first_1));
305
- void (items.push(parseTypeRef()));
348
+ const items_2 = [];
349
+ void (items_2.push(first_1));
350
+ void (items_2.push(parseTypeRef()));
306
351
  while (TokenStream__Match_5CEB78CD(stream, TokenKind.Star)) {
307
- void (items.push(parseTypeRef()));
352
+ void (items_2.push(parseTypeRef()));
308
353
  }
309
354
  TokenStream__Expect_77B9EE56(stream, TokenKind.RParen, "Expected \')\' in tuple type");
310
- return new TypeRef(/* TRTuple */ 1, [toList(items)]);
355
+ return new TypeRef(/* TRTuple */ 1, [toList(items_2)]);
311
356
  }
312
357
  else {
313
358
  TokenStream__Expect_77B9EE56(stream, TokenKind.RParen, "Expected \')\' in type expression");
@@ -322,34 +367,34 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
322
367
  let t = parseTypeRefAtom();
323
368
  let loop = true;
324
369
  while (loop) {
325
- const matchValue_7 = TokenStream__Peek(stream).Kind;
326
- let matchResult;
327
- if (matchValue_7.tag === 4) {
328
- switch (matchValue_7.fields[0]) {
370
+ const matchValue_8 = TokenStream__Peek(stream).Kind;
371
+ let matchResult_1;
372
+ if (matchValue_8.tag === 4) {
373
+ switch (matchValue_8.fields[0]) {
329
374
  case "list": {
330
- matchResult = 0;
375
+ matchResult_1 = 0;
331
376
  break;
332
377
  }
333
378
  case "option": {
334
- matchResult = 1;
379
+ matchResult_1 = 1;
335
380
  break;
336
381
  }
337
382
  case "map": {
338
- matchResult = 2;
383
+ matchResult_1 = 2;
339
384
  break;
340
385
  }
341
386
  case "task": {
342
- matchResult = 3;
387
+ matchResult_1 = 3;
343
388
  break;
344
389
  }
345
390
  default:
346
- matchResult = 4;
391
+ matchResult_1 = 4;
347
392
  }
348
393
  }
349
394
  else {
350
- matchResult = 4;
395
+ matchResult_1 = 4;
351
396
  }
352
- switch (matchResult) {
397
+ switch (matchResult_1) {
353
398
  case 0: {
354
399
  TokenStream__Next(stream);
355
400
  t = (new TypeRef(/* TRPostfix */ 3, [t, "list"]));
@@ -396,10 +441,10 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
396
441
  };
397
442
  const parseParam = () => {
398
443
  TokenStream__SkipNewlines(stream);
399
- const matchValue_8 = TokenStream__Peek(stream).Kind;
400
- switch (matchValue_8.tag) {
444
+ const matchValue_9 = TokenStream__Peek(stream).Kind;
445
+ switch (matchValue_9.tag) {
401
446
  case 4:
402
- return new Param(matchValue_8.fields[0], undefined, TokenStream__Next(stream).Span);
447
+ return new Param(matchValue_9.fields[0], undefined, TokenStream__Next(stream).Span);
403
448
  case 27: {
404
449
  const lp = TokenStream__Next(stream);
405
450
  TokenStream__SkipNewlines(stream);
@@ -408,8 +453,8 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
408
453
  }
409
454
  else {
410
455
  let name;
411
- const matchValue_9 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected parameter name in annotated parameter").Kind;
412
- name = ((matchValue_9.tag === 4) ? matchValue_9.fields[0] : "");
456
+ const matchValue_10 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected parameter name in annotated parameter").Kind;
457
+ name = ((matchValue_10.tag === 4) ? matchValue_10.fields[0] : "");
413
458
  TokenStream__SkipNewlines(stream);
414
459
  TokenStream__Expect_77B9EE56(stream, TokenKind.Colon, "Expected \':\' in annotated parameter");
415
460
  return new Param(name, parseTypeRef(), mkSpanFrom(lp.Span, TokenStream__Expect_77B9EE56(stream, TokenKind.RParen, "Expected \')\' after annotated parameter").Span));
@@ -432,8 +477,8 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
432
477
  }
433
478
  while (TokenStream__Match_5CEB78CD(stream, TokenKind.Dedent)) {
434
479
  }
435
- const matchValue_10 = TokenStream__Peek(stream).Kind;
436
- switch (matchValue_10.tag) {
480
+ const matchValue_11 = TokenStream__Peek(stream).Kind;
481
+ switch (matchValue_11.tag) {
437
482
  case 4:
438
483
  case 27: {
439
484
  const param = parseParam();
@@ -456,12 +501,12 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
456
501
  return args;
457
502
  };
458
503
  const parseTypeDecl = (backendImport) => {
459
- let option_1, attribute, matchValue_16;
504
+ let attribute, matchValue_17;
460
505
  const typeTok = TokenStream__Expect_77B9EE56(stream, TokenKind.Type, "Expected \'type\'");
461
506
  const isRec = TokenStream__Match_5CEB78CD(stream, TokenKind.Rec);
462
507
  let name_1;
463
- const matchValue_11 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'type\'").Kind;
464
- name_1 = ((matchValue_11.tag === 4) ? matchValue_11.fields[0] : "");
508
+ const matchValue_12 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'type\'").Kind;
509
+ name_1 = ((matchValue_12.tag === 4) ? matchValue_12.fields[0] : "");
465
510
  TokenStream__SkipNewlines(stream);
466
511
  TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' in type declaration");
467
512
  let hasOuterIndent = false;
@@ -472,9 +517,10 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
472
517
  hasOuterIndent = true;
473
518
  }
474
519
  }
520
+ const labels_2 = fieldLabels();
475
521
  let patternInput_1;
476
- const matchValue_15 = TokenStream__Peek(stream).Kind;
477
- switch (matchValue_15.tag) {
522
+ const matchValue_16 = TokenStream__Peek(stream).Kind;
523
+ switch (matchValue_16.tag) {
478
524
  case 43: {
479
525
  const lbIndex = TokenStream__get_Index(stream) | 0;
480
526
  const lb = TokenStream__Expect_77B9EE56(stream, TokenKind.LBrace, "Expected \'{\' in record type declaration");
@@ -486,11 +532,12 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
486
532
  TokenStream__SkipNewlines(stream);
487
533
  const fieldTok = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name in type declaration");
488
534
  let fieldName_1;
489
- const matchValue_12 = fieldTok.Kind;
490
- fieldName_1 = ((matchValue_12.tag === 4) ? matchValue_12.fields[0] : "");
535
+ const matchValue_13 = fieldTok.Kind;
536
+ fieldName_1 = ((matchValue_13.tag === 4) ? matchValue_13.fields[0] : "");
491
537
  TokenStream__SkipNewlines(stream);
492
538
  TokenStream__Expect_77B9EE56(stream, TokenKind.Colon, "Expected \':\' after field name");
493
539
  const fieldType_1 = parseTypeRef();
540
+ addFieldLabel(labels_2, fieldTok);
494
541
  void (fields_1.push([fieldName_1, fieldType_1]));
495
542
  return fieldTok.Span.Start.Column | 0;
496
543
  };
@@ -515,8 +562,8 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
515
562
  while (TokenStream__Match_5CEB78CD(stream, TokenKind.Dedent)) {
516
563
  }
517
564
  if (sawNewline_1) {
518
- const matchValue_13 = TokenStream__Peek(stream).Kind;
519
- switch (matchValue_13.tag) {
565
+ const matchValue_14 = TokenStream__Peek(stream).Kind;
566
+ switch (matchValue_14.tag) {
520
567
  case 44: {
521
568
  doneFields = true;
522
569
  break;
@@ -552,8 +599,8 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
552
599
  TokenStream__Match_5CEB78CD(stream, TokenKind.Bar);
553
600
  const caseTok = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected union case name");
554
601
  let caseName;
555
- const matchValue_14 = caseTok.Kind;
556
- caseName = ((matchValue_14.tag === 4) ? matchValue_14.fields[0] : "");
602
+ const matchValue_15 = caseTok.Kind;
603
+ caseName = ((matchValue_15.tag === 4) ? matchValue_15.fields[0] : "");
557
604
  if (!isUpperIdent(caseName)) {
558
605
  throw new ParseException(new ParseError("Union case name must start with uppercase letter", caseTok.Span));
559
606
  }
@@ -596,7 +643,9 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
596
643
  while (TokenStream__Match_5CEB78CD(stream, TokenKind.Dedent)) {
597
644
  }
598
645
  }
599
- return new Stmt(/* SType */ 0, [new TypeDef(name_1, isRec, patternInput_1[0], patternInput_1[1], (option_1 = backendImport, (option_1 != null) ? ((attribute = option_1, (matchValue_16 = attribute.Arguments, !isEmpty(matchValue_16) ? (!isEmpty(tail_1(matchValue_16)) ? (isEmpty(tail_1(tail_1(matchValue_16))) ? ((!isNullOrWhiteSpace(head_1(matchValue_16)) && !isNullOrWhiteSpace(head_1(tail_1(matchValue_16)))) ? (new BackendImport(head_1(matchValue_16), head_1(tail_1(matchValue_16)), attribute.Span)) : (() => {
646
+ let import$;
647
+ const option_5 = backendImport;
648
+ import$ = ((option_5 != null) ? ((attribute = option_5, (matchValue_17 = attribute.Arguments, !isEmpty(matchValue_17) ? (!isEmpty(tail_1(matchValue_17)) ? (isEmpty(tail_1(tail_1(matchValue_17))) ? ((!isNullOrWhiteSpace(head_1(matchValue_17)) && !isNullOrWhiteSpace(head_1(tail_1(matchValue_17)))) ? (new BackendImport(head_1(matchValue_17), head_1(tail_1(matchValue_17)), attribute.Span)) : (() => {
600
649
  throw new ParseException(new ParseError("Import requires module path and member name: [<Import(\"module/path\", \"Member\")>]", attribute.Span));
601
650
  })()) : (() => {
602
651
  throw new ParseException(new ParseError("Import requires module path and member name: [<Import(\"module/path\", \"Member\")>]", attribute.Span));
@@ -604,48 +653,51 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
604
653
  throw new ParseException(new ParseError("Import requires module path and member name: [<Import(\"module/path\", \"Member\")>]", attribute.Span));
605
654
  })()) : (() => {
606
655
  throw new ParseException(new ParseError("Import requires module path and member name: [<Import(\"module/path\", \"Member\")>]", attribute.Span));
607
- })()))) : undefined), mkSpanFrom(typeTok.Span, patternInput_1[2]))]);
656
+ })()))) : undefined);
657
+ const span_2 = mkSpanFrom(typeTok.Span, patternInput_1[2]);
658
+ recordFieldLabels(span_2, labels_2);
659
+ return new Stmt(/* SType */ 0, [new TypeDef(name_1, isRec, patternInput_1[0], patternInput_1[1], import$, span_2)]);
608
660
  };
609
661
  const parsePattern = () => {
610
662
  TokenStream__SkipNewlines(stream);
611
663
  const t_1 = TokenStream__Peek(stream);
612
- const matchValue_17 = t_1.Kind;
613
- let matchResult_1, name_3, name_4;
614
- switch (matchValue_17.tag) {
664
+ const matchValue_18 = t_1.Kind;
665
+ let matchResult_2, name_3, name_4;
666
+ switch (matchValue_18.tag) {
615
667
  case 5:
616
668
  case 6:
617
669
  case 7:
618
670
  case 9: {
619
- matchResult_1 = 2;
671
+ matchResult_2 = 2;
620
672
  break;
621
673
  }
622
674
  case 29: {
623
- matchResult_1 = 3;
675
+ matchResult_2 = 3;
624
676
  break;
625
677
  }
626
678
  case 27: {
627
- matchResult_1 = 4;
679
+ matchResult_2 = 4;
628
680
  break;
629
681
  }
630
682
  case 43: {
631
- matchResult_1 = 5;
683
+ matchResult_2 = 5;
632
684
  break;
633
685
  }
634
686
  case 4: {
635
- if (matchValue_17.fields[0] === "_") {
636
- matchResult_1 = 0;
637
- name_3 = matchValue_17.fields[0];
687
+ if (matchValue_18.fields[0] === "_") {
688
+ matchResult_2 = 0;
689
+ name_3 = matchValue_18.fields[0];
638
690
  }
639
691
  else {
640
- matchResult_1 = 1;
641
- name_4 = matchValue_17.fields[0];
692
+ matchResult_2 = 1;
693
+ name_4 = matchValue_18.fields[0];
642
694
  }
643
695
  break;
644
696
  }
645
697
  default:
646
- matchResult_1 = 6;
698
+ matchResult_2 = 6;
647
699
  }
648
- switch (matchResult_1) {
700
+ switch (matchResult_2) {
649
701
  case 0:
650
702
  return new Pattern(/* PWildcard */ 0, [TokenStream__Next(stream).Span]);
651
703
  case 1: {
@@ -653,8 +705,8 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
653
705
  if (isUpperIdent(name_4) && TokenStream__Match_5CEB78CD(stream, TokenKind.Dot)) {
654
706
  const caseTok_1 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected union case name after \'.\'");
655
707
  let caseName_1;
656
- const matchValue_18 = caseTok_1.Kind;
657
- caseName_1 = ((matchValue_18.tag === 4) ? matchValue_18.fields[0] : "");
708
+ const matchValue_19 = caseTok_1.Kind;
709
+ caseName_1 = ((matchValue_19.tag === 4) ? matchValue_19.fields[0] : "");
658
710
  if (!isUpperIdent(caseName_1)) {
659
711
  throw new ParseException(new ParseError("Union case name must start with uppercase letter", caseTok_1.Span));
660
712
  }
@@ -755,8 +807,8 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
755
807
  const parseTypeField = () => {
756
808
  const nameTok_3 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name in structural record type pattern");
757
809
  let fieldName_2;
758
- const matchValue_19 = nameTok_3.Kind;
759
- fieldName_2 = ((matchValue_19.tag === 4) ? matchValue_19.fields[0] : "");
810
+ const matchValue_20 = nameTok_3.Kind;
811
+ fieldName_2 = ((matchValue_20.tag === 4) ? matchValue_20.fields[0] : "");
760
812
  if (!addToSet(fieldName_2, seen_1)) {
761
813
  throw new ParseException(new ParseError(concat("Duplicate field \'", fieldName_2, "\' in structural record type pattern"), nameTok_3.Span));
762
814
  }
@@ -842,7 +894,7 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
842
894
  TokenStream__SkipNewlines(stream);
843
895
  isTypeRefPattern = TokenStream__Match_5CEB78CD(stream, TokenKind.Colon);
844
896
  }
845
- catch (matchValue_20) {
897
+ catch (matchValue_21) {
846
898
  isTypeRefPattern = false;
847
899
  }
848
900
  TokenStream__Restore_Z524259A4(stream, mark);
@@ -853,8 +905,8 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
853
905
  TokenStream__SkipNewlines(stream);
854
906
  const nameTok_4 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name in record type pattern");
855
907
  let name_5;
856
- const matchValue_21 = nameTok_4.Kind;
857
- name_5 = ((matchValue_21.tag === 4) ? matchValue_21.fields[0] : "");
908
+ const matchValue_22 = nameTok_4.Kind;
909
+ name_5 = ((matchValue_22.tag === 4) ? matchValue_22.fields[0] : "");
858
910
  if (!addToSet(name_5, seen_2)) {
859
911
  throw new ParseException(new ParseError(concat("Duplicate field \'", name_5, "\' in record type pattern"), nameTok_4.Span));
860
912
  }
@@ -883,8 +935,8 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
883
935
  TokenStream__SkipNewlines(stream);
884
936
  const nameTok_5 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name in record pattern");
885
937
  let name_6;
886
- const matchValue_22 = nameTok_5.Kind;
887
- name_6 = ((matchValue_22.tag === 4) ? matchValue_22.fields[0] : "");
938
+ const matchValue_23 = nameTok_5.Kind;
939
+ name_6 = ((matchValue_23.tag === 4) ? matchValue_23.fields[0] : "");
888
940
  if (!addToSet(name_6, seen_3)) {
889
941
  throw new ParseException(new ParseError(concat("Duplicate field \'", name_6, "\' in record pattern"), nameTok_5.Span));
890
942
  }
@@ -946,103 +998,103 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
946
998
  }
947
999
  };
948
1000
  const parsePrimary = () => {
949
- let matchValue_30, matchValue_31;
1001
+ let matchValue_31, matchValue_32;
950
1002
  TokenStream__SkipNewlines(stream);
951
1003
  const t_6 = TokenStream__Peek(stream);
952
- const matchValue_23 = t_6.Kind;
953
- let matchResult_2, raw_1, name_7;
954
- switch (matchValue_23.tag) {
1004
+ const matchValue_24 = t_6.Kind;
1005
+ let matchResult_3, raw_1, name_7;
1006
+ switch (matchValue_24.tag) {
955
1007
  case 5:
956
1008
  case 6:
957
1009
  case 7:
958
1010
  case 9: {
959
- matchResult_2 = 0;
1011
+ matchResult_3 = 0;
960
1012
  break;
961
1013
  }
962
1014
  case 27: {
963
- matchResult_2 = 4;
1015
+ matchResult_3 = 4;
964
1016
  break;
965
1017
  }
966
1018
  case 29: {
967
- matchResult_2 = 5;
1019
+ matchResult_3 = 5;
968
1020
  break;
969
1021
  }
970
1022
  case 43: {
971
- matchResult_2 = 6;
1023
+ matchResult_3 = 6;
972
1024
  break;
973
1025
  }
974
1026
  case 10: {
975
- matchResult_2 = 7;
1027
+ matchResult_3 = 7;
976
1028
  break;
977
1029
  }
978
1030
  case 13: {
979
- matchResult_2 = 8;
1031
+ matchResult_3 = 8;
980
1032
  break;
981
1033
  }
982
1034
  case 17: {
983
- matchResult_2 = 9;
1035
+ matchResult_3 = 9;
984
1036
  break;
985
1037
  }
986
1038
  case 21: {
987
- matchResult_2 = 10;
1039
+ matchResult_3 = 10;
988
1040
  break;
989
1041
  }
990
1042
  case 22: {
991
- matchResult_2 = 11;
1043
+ matchResult_3 = 11;
992
1044
  break;
993
1045
  }
994
1046
  case 14: {
995
- matchResult_2 = 12;
1047
+ matchResult_3 = 12;
996
1048
  break;
997
1049
  }
998
1050
  case 46: {
999
- matchResult_2 = 13;
1051
+ matchResult_3 = 13;
1000
1052
  break;
1001
1053
  }
1002
1054
  case 47: {
1003
- matchResult_2 = 14;
1055
+ matchResult_3 = 14;
1004
1056
  break;
1005
1057
  }
1006
1058
  case 2: {
1007
- matchResult_2 = 15;
1059
+ matchResult_3 = 15;
1008
1060
  break;
1009
1061
  }
1010
1062
  case 3: {
1011
- matchResult_2 = 16;
1063
+ matchResult_3 = 16;
1012
1064
  break;
1013
1065
  }
1014
1066
  case 8: {
1015
- matchResult_2 = 1;
1016
- raw_1 = matchValue_23.fields[0];
1067
+ matchResult_3 = 1;
1068
+ raw_1 = matchValue_24.fields[0];
1017
1069
  break;
1018
1070
  }
1019
1071
  case 4: {
1020
- if (matchValue_23.fields[0] === "export") {
1072
+ if (matchValue_24.fields[0] === "export") {
1021
1073
  if (equals(TokenStream__PeekAt_Z524259A4(stream, 1).Kind, TokenKind.Let)) {
1022
- matchResult_2 = 2;
1074
+ matchResult_3 = 2;
1023
1075
  }
1024
1076
  else {
1025
- matchResult_2 = 3;
1026
- name_7 = matchValue_23.fields[0];
1077
+ matchResult_3 = 3;
1078
+ name_7 = matchValue_24.fields[0];
1027
1079
  }
1028
1080
  }
1029
1081
  else {
1030
- matchResult_2 = 3;
1031
- name_7 = matchValue_23.fields[0];
1082
+ matchResult_3 = 3;
1083
+ name_7 = matchValue_24.fields[0];
1032
1084
  }
1033
1085
  break;
1034
1086
  }
1035
1087
  default:
1036
- matchResult_2 = 17;
1088
+ matchResult_3 = 17;
1037
1089
  }
1038
- switch (matchResult_2) {
1090
+ switch (matchResult_3) {
1039
1091
  case 0: {
1040
1092
  const t_7 = TokenStream__Next(stream);
1041
1093
  return new Expr(/* ELiteral */ 1, [parseLiteral(t_7), t_7.Span]);
1042
1094
  }
1043
1095
  case 1: {
1044
1096
  const raw = raw_1;
1045
- const span = TokenStream__Next(stream).Span;
1097
+ const span_1 = TokenStream__Next(stream).Span;
1046
1098
  const parts = [];
1047
1099
  const text = StringBuilder_$ctor();
1048
1100
  const flushText = () => {
@@ -1054,43 +1106,43 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
1054
1106
  let i_1 = 0;
1055
1107
  while (i_1 < raw.length) {
1056
1108
  let parsed;
1057
- const matchValue = getCharAtIndex(raw, i_1);
1058
- let matchResult_3, ch_1;
1059
- switch (matchValue) {
1109
+ const matchValue_1 = getCharAtIndex(raw, i_1);
1110
+ let matchResult_4, ch_1;
1111
+ switch (matchValue_1) {
1060
1112
  case "\\": {
1061
1113
  if ((i_1 + 1) < raw.length) {
1062
- matchResult_3 = 4;
1114
+ matchResult_4 = 4;
1063
1115
  }
1064
1116
  else {
1065
- matchResult_3 = 5;
1066
- ch_1 = matchValue;
1117
+ matchResult_4 = 5;
1118
+ ch_1 = matchValue_1;
1067
1119
  }
1068
1120
  break;
1069
1121
  }
1070
1122
  case "{": {
1071
1123
  if (((i_1 + 1) < raw.length) && (getCharAtIndex(raw, i_1 + 1) === "{")) {
1072
- matchResult_3 = 0;
1124
+ matchResult_4 = 0;
1073
1125
  }
1074
1126
  else {
1075
- matchResult_3 = 2;
1127
+ matchResult_4 = 2;
1076
1128
  }
1077
1129
  break;
1078
1130
  }
1079
1131
  case "}": {
1080
1132
  if (((i_1 + 1) < raw.length) && (getCharAtIndex(raw, i_1 + 1) === "}")) {
1081
- matchResult_3 = 1;
1133
+ matchResult_4 = 1;
1082
1134
  }
1083
1135
  else {
1084
- matchResult_3 = 3;
1136
+ matchResult_4 = 3;
1085
1137
  }
1086
1138
  break;
1087
1139
  }
1088
1140
  default: {
1089
- matchResult_3 = 5;
1090
- ch_1 = matchValue;
1141
+ matchResult_4 = 5;
1142
+ ch_1 = matchValue_1;
1091
1143
  }
1092
1144
  }
1093
- switch (matchResult_3) {
1145
+ switch (matchResult_4) {
1094
1146
  case 0: {
1095
1147
  StringBuilder__Append_244C7CD6(text, "{");
1096
1148
  i_1 = ((i_1 + 2) | 0);
@@ -1157,14 +1209,14 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
1157
1209
  }
1158
1210
  }
1159
1211
  if (depth !== 0) {
1160
- throw new ParseException(new ParseError("Unterminated interpolation placeholder", span));
1212
+ throw new ParseException(new ParseError("Unterminated interpolation placeholder", span_1));
1161
1213
  }
1162
1214
  const exprText_1 = substring(s, start, (i - start) - 1);
1163
1215
  if (isNullOrWhiteSpace(exprText_1)) {
1164
- throw new ParseException(new ParseError("Interpolation placeholder cannot be empty", span));
1216
+ throw new ParseException(new ParseError("Interpolation placeholder cannot be empty", span_1));
1165
1217
  }
1166
- let originLine_1 = span.Start.Line;
1167
- let originColumn_1 = span.Start.Column + 2;
1218
+ let originLine_1 = span_1.Start.Line;
1219
+ let originColumn_1 = span_1.Start.Column + 2;
1168
1220
  for (let offset = 0; offset <= (start - 1); offset++) {
1169
1221
  if (getCharAtIndex(s, offset) === "\n") {
1170
1222
  originLine_1 = ((originLine_1 + 1) | 0);
@@ -1174,7 +1226,7 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
1174
1226
  originColumn_1 = ((originColumn_1 + 1) | 0);
1175
1227
  }
1176
1228
  }
1177
- patternInput = [(parsed = parseProgramWithSourceNameAndOrigin(sourceName, originLine_1, originColumn_1, exprText_1), !isEmpty(parsed) ? ((head_1(parsed).tag === 7) ? (isEmpty(tail_1(parsed)) ? head_1(parsed).fields[0] : (() => {
1229
+ patternInput = [(parsed = parseProgramWithSourceNameAndOrigin(captureFieldLabels, sourceName, originLine_1, originColumn_1, exprText_1), !isEmpty(parsed) ? ((head_1(parsed).tag === 7) ? (isEmpty(tail_1(parsed)) ? head_1(parsed).fields[0] : (() => {
1178
1230
  throw new ParseException(new ParseError("Interpolation placeholders must contain a single expression", TokenStream__Peek(stream).Span));
1179
1231
  })()) : (() => {
1180
1232
  throw new ParseException(new ParseError("Interpolation placeholders must contain a single expression", TokenStream__Peek(stream).Span));
@@ -1186,7 +1238,7 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
1186
1238
  break;
1187
1239
  }
1188
1240
  case 3: {
1189
- throw new ParseException(new ParseError("Unescaped \'}\' in interpolated string", span));
1241
+ throw new ParseException(new ParseError("Unescaped \'}\' in interpolated string", span_1));
1190
1242
  break;
1191
1243
  }
1192
1244
  case 4: {
@@ -1222,7 +1274,7 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
1222
1274
  }
1223
1275
  }
1224
1276
  flushText();
1225
- return new Expr(/* EInterpolatedString */ 30, [(parts.length === 0) ? singleton(new InterpolatedPart(/* IPText */ 0, [""])) : toList(parts), span]);
1277
+ return new Expr(/* EInterpolatedString */ 30, [(parts.length === 0) ? singleton(new InterpolatedPart(/* IPText */ 0, [""])) : toList(parts), span_1]);
1226
1278
  }
1227
1279
  case 2:
1228
1280
  throw new ParseException(new ParseError("\'export let\' is only supported at top level", t_6.Span));
@@ -1316,19 +1368,19 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
1316
1368
  throw new ParseException(new ParseError("Structural record literal must define at least one field", TokenStream__Peek(stream).Span));
1317
1369
  }
1318
1370
  const mark_1 = TokenStream__Mark(stream) | 0;
1319
- let matchValue_25;
1371
+ let matchValue_26;
1320
1372
  const baseExpr = parseExpr();
1321
1373
  TokenStream__SkipNewlines(stream);
1322
1374
  if (!TokenStream__Match_5CEB78CD(stream, TokenKind.With)) {
1323
1375
  TokenStream__Restore_Z524259A4(stream, mark_1);
1324
- matchValue_25 = undefined;
1376
+ matchValue_26 = undefined;
1325
1377
  }
1326
1378
  else {
1327
1379
  const updates = [];
1328
1380
  const parseUpdateField = () => {
1329
1381
  let name_8;
1330
- const matchValue_24 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name in structural record update").Kind;
1331
- name_8 = ((matchValue_24.tag === 4) ? matchValue_24.fields[0] : "");
1382
+ const matchValue_25 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name in structural record update").Kind;
1383
+ name_8 = ((matchValue_25.tag === 4) ? matchValue_25.fields[0] : "");
1332
1384
  TokenStream__SkipNewlines(stream);
1333
1385
  TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' in structural record update field");
1334
1386
  const value_41 = parseEntryExpr();
@@ -1350,14 +1402,14 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
1350
1402
  if (!hasNonLayoutTokenBeforeOnSameLine(rbIndex_7, rb_8.Span.Start.Line)) {
1351
1403
  throw new ParseException(new ParseError("Closing \'}\' cannot be on its own line; keep it with the last entry", rb_8.Span));
1352
1404
  }
1353
- matchValue_25 = (new Expr(/* EStructuralRecordUpdate */ 20, [baseExpr, toList(updates), mkSpanFrom(lb_4.Span, rb_8.Span)]));
1405
+ matchValue_26 = (new Expr(/* EStructuralRecordUpdate */ 20, [baseExpr, toList(updates), mkSpanFrom(lb_4.Span, rb_8.Span)]));
1354
1406
  }
1355
- if (matchValue_25 == null) {
1407
+ if (matchValue_26 == null) {
1356
1408
  const fields_6 = [];
1357
1409
  const parseField_3 = () => {
1358
1410
  let name_9;
1359
- const matchValue_26 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name in structural record literal").Kind;
1360
- name_9 = ((matchValue_26.tag === 4) ? matchValue_26.fields[0] : "");
1411
+ const matchValue_27 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name in structural record literal").Kind;
1412
+ name_9 = ((matchValue_27.tag === 4) ? matchValue_27.fields[0] : "");
1361
1413
  TokenStream__SkipNewlines(stream);
1362
1414
  TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' in structural record field");
1363
1415
  const value_45 = parseEntryExpr();
@@ -1382,7 +1434,7 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
1382
1434
  return new Expr(/* EStructuralRecord */ 17, [toList(fields_6), mkSpanFrom(lb_4.Span, rb_9.Span)]);
1383
1435
  }
1384
1436
  else {
1385
- return matchValue_25;
1437
+ return matchValue_26;
1386
1438
  }
1387
1439
  }
1388
1440
  else if (equals(TokenStream__Peek(stream).Kind, TokenKind.LBracket) ? true : equals(TokenStream__Peek(stream).Kind, TokenKind.RangeDots)) {
@@ -1427,19 +1479,19 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
1427
1479
  }
1428
1480
  else {
1429
1481
  const mark_2 = TokenStream__Mark(stream) | 0;
1430
- let matchValue_28;
1482
+ let matchValue_29;
1431
1483
  const baseExpr_1 = parseExpr();
1432
1484
  TokenStream__SkipNewlines(stream);
1433
1485
  if (!TokenStream__Match_5CEB78CD(stream, TokenKind.With)) {
1434
1486
  TokenStream__Restore_Z524259A4(stream, mark_2);
1435
- matchValue_28 = undefined;
1487
+ matchValue_29 = undefined;
1436
1488
  }
1437
1489
  else {
1438
1490
  const updates_1 = [];
1439
1491
  const parseUpdateField_1 = () => {
1440
1492
  let name_10;
1441
- const matchValue_27 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name in record update").Kind;
1442
- name_10 = ((matchValue_27.tag === 4) ? matchValue_27.fields[0] : "");
1493
+ const matchValue_28 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name in record update").Kind;
1494
+ name_10 = ((matchValue_28.tag === 4) ? matchValue_28.fields[0] : "");
1443
1495
  TokenStream__SkipNewlines(stream);
1444
1496
  TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' in record update field");
1445
1497
  const value_54 = parseEntryExpr();
@@ -1460,14 +1512,17 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
1460
1512
  if (!hasNonLayoutTokenBeforeOnSameLine(rbIndex_10, rb_11.Span.Start.Line)) {
1461
1513
  throw new ParseException(new ParseError("Closing \'}\' cannot be on its own line; keep it with the last entry", rb_11.Span));
1462
1514
  }
1463
- matchValue_28 = (new Expr(/* ERecordUpdate */ 19, [baseExpr_1, toList(updates_1), mkSpanFrom(lb_4.Span, rb_11.Span)]));
1515
+ matchValue_29 = (new Expr(/* ERecordUpdate */ 19, [baseExpr_1, toList(updates_1), mkSpanFrom(lb_4.Span, rb_11.Span)]));
1464
1516
  }
1465
- if (matchValue_28 == null) {
1517
+ if (matchValue_29 == null) {
1466
1518
  const fields_7 = [];
1519
+ const labels_3 = fieldLabels();
1467
1520
  const parseField_4 = () => {
1521
+ const nameTok_9 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name in record literal");
1522
+ addFieldLabel(labels_3, nameTok_9);
1468
1523
  let name_11;
1469
- const matchValue_29 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name in record literal").Kind;
1470
- name_11 = ((matchValue_29.tag === 4) ? matchValue_29.fields[0] : "");
1524
+ const matchValue_30 = nameTok_9.Kind;
1525
+ name_11 = ((matchValue_30.tag === 4) ? matchValue_30.fields[0] : "");
1471
1526
  TokenStream__SkipNewlines(stream);
1472
1527
  TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' in record field");
1473
1528
  const value_57 = parseEntryExpr();
@@ -1488,10 +1543,12 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
1488
1543
  if (!hasNonLayoutTokenBeforeOnSameLine(rbIndex_11, rb_12.Span.Start.Line)) {
1489
1544
  throw new ParseException(new ParseError("Closing \'}\' cannot be on its own line; keep it with the last entry", rb_12.Span));
1490
1545
  }
1491
- return new Expr(/* ERecord */ 16, [toList(fields_7), mkSpanFrom(lb_4.Span, rb_12.Span)]);
1546
+ const span_3 = mkSpanFrom(lb_4.Span, rb_12.Span);
1547
+ recordFieldLabels(span_3, labels_3);
1548
+ return new Expr(/* ERecord */ 16, [toList(fields_7), span_3]);
1492
1549
  }
1493
1550
  else {
1494
- return matchValue_28;
1551
+ return matchValue_29;
1495
1552
  }
1496
1553
  }
1497
1554
  }
@@ -1513,12 +1570,12 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
1513
1570
  case 13: {
1514
1571
  const t_10 = TokenStream__Next(stream);
1515
1572
  const nameTok_10 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected type name after \'typeof\'");
1516
- return new Expr(/* ETypeOf */ 28, [(matchValue_30 = nameTok_10.Kind, (matchValue_30.tag === 4) ? matchValue_30.fields[0] : ""), mkSpanFrom(t_10.Span, nameTok_10.Span)]);
1573
+ return new Expr(/* ETypeOf */ 28, [(matchValue_31 = nameTok_10.Kind, (matchValue_31.tag === 4) ? matchValue_31.fields[0] : ""), mkSpanFrom(t_10.Span, nameTok_10.Span)]);
1517
1574
  }
1518
1575
  case 14: {
1519
1576
  const t_11 = TokenStream__Next(stream);
1520
1577
  const nameTok_11 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'nameof\'");
1521
- return new Expr(/* ENameOf */ 29, [(matchValue_31 = nameTok_11.Kind, (matchValue_31.tag === 4) ? matchValue_31.fields[0] : ""), mkSpanFrom(t_11.Span, nameTok_11.Span)]);
1578
+ return new Expr(/* ENameOf */ 29, [(matchValue_32 = nameTok_11.Kind, (matchValue_32.tag === 4) ? matchValue_32.fields[0] : ""), mkSpanFrom(t_11.Span, nameTok_11.Span)]);
1522
1579
  }
1523
1580
  case 15:
1524
1581
  throw new ParseException(new ParseError("Indentation error: unexpected indent in expression", t_6.Span));
@@ -1535,8 +1592,8 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
1535
1592
  if (TokenStream__Match_5CEB78CD(stream, TokenKind.Dot)) {
1536
1593
  const fieldTok_1 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name after \'.\'");
1537
1594
  let fieldName_3;
1538
- const matchValue_32 = fieldTok_1.Kind;
1539
- fieldName_3 = ((matchValue_32.tag === 4) ? matchValue_32.fields[0] : "");
1595
+ const matchValue_33 = fieldTok_1.Kind;
1596
+ fieldName_3 = ((matchValue_33.tag === 4) ? matchValue_33.fields[0] : "");
1540
1597
  expr_3 = (new Expr(/* EFieldGet */ 21, [expr_3, fieldName_3, mkSpanFrom(Ast_spanOfExpr(expr_3), fieldTok_1.Span)]));
1541
1598
  }
1542
1599
  else if (equals(TokenStream__Peek(stream).Kind, TokenKind.LBracket)) {
@@ -1679,8 +1736,8 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
1679
1736
  TokenStream__SkipNewlines(stream);
1680
1737
  }
1681
1738
  let elseExpr;
1682
- const matchValue_33 = TokenStream__Peek(stream).Kind;
1683
- switch (matchValue_33.tag) {
1739
+ const matchValue_34 = TokenStream__Peek(stream).Kind;
1740
+ switch (matchValue_34.tag) {
1684
1741
  case 19: {
1685
1742
  TokenStream__Next(stream);
1686
1743
  elseExpr = parseExprOrBlock();
@@ -1698,23 +1755,23 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
1698
1755
  const parseFor = () => {
1699
1756
  const forTok = TokenStream__Expect_77B9EE56(stream, TokenKind.For, "Expected \'for\'");
1700
1757
  let name_14;
1701
- const matchValue_34 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'for\'").Kind;
1702
- name_14 = ((matchValue_34.tag === 4) ? matchValue_34.fields[0] : "");
1758
+ const matchValue_35 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'for\'").Kind;
1759
+ name_14 = ((matchValue_35.tag === 4) ? matchValue_35.fields[0] : "");
1703
1760
  TokenStream__SkipNewlines(stream);
1704
- const matchValue_35 = TokenStream__Peek(stream).Kind;
1705
- let matchResult_4;
1706
- if (matchValue_35.tag === 4) {
1707
- if (matchValue_35.fields[0] === "in") {
1708
- matchResult_4 = 0;
1761
+ const matchValue_36 = TokenStream__Peek(stream).Kind;
1762
+ let matchResult_5;
1763
+ if (matchValue_36.tag === 4) {
1764
+ if (matchValue_36.fields[0] === "in") {
1765
+ matchResult_5 = 0;
1709
1766
  }
1710
1767
  else {
1711
- matchResult_4 = 1;
1768
+ matchResult_5 = 1;
1712
1769
  }
1713
1770
  }
1714
1771
  else {
1715
- matchResult_4 = 1;
1772
+ matchResult_5 = 1;
1716
1773
  }
1717
- switch (matchResult_4) {
1774
+ switch (matchResult_5) {
1718
1775
  case 0: {
1719
1776
  TokenStream__Next(stream);
1720
1777
  break;
@@ -1726,20 +1783,20 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
1726
1783
  }
1727
1784
  const source_19 = parsePostfix();
1728
1785
  TokenStream__SkipNewlines(stream);
1729
- const matchValue_36 = TokenStream__Peek(stream).Kind;
1730
- let matchResult_5;
1731
- if (matchValue_36.tag === 4) {
1732
- if (matchValue_36.fields[0] === "do") {
1733
- matchResult_5 = 0;
1786
+ const matchValue_37 = TokenStream__Peek(stream).Kind;
1787
+ let matchResult_6;
1788
+ if (matchValue_37.tag === 4) {
1789
+ if (matchValue_37.fields[0] === "do") {
1790
+ matchResult_6 = 0;
1734
1791
  }
1735
1792
  else {
1736
- matchResult_5 = 1;
1793
+ matchResult_6 = 1;
1737
1794
  }
1738
1795
  }
1739
1796
  else {
1740
- matchResult_5 = 1;
1797
+ matchResult_6 = 1;
1741
1798
  }
1742
- switch (matchResult_5) {
1799
+ switch (matchResult_6) {
1743
1800
  case 0: {
1744
1801
  TokenStream__Next(stream);
1745
1802
  break;
@@ -1758,8 +1815,8 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
1758
1815
  let doneParams = false;
1759
1816
  while (!doneParams) {
1760
1817
  TokenStream__SkipNewlines(stream);
1761
- const matchValue_37 = TokenStream__Peek(stream).Kind;
1762
- switch (matchValue_37.tag) {
1818
+ const matchValue_38 = TokenStream__Peek(stream).Kind;
1819
+ switch (matchValue_38.tag) {
1763
1820
  case 4:
1764
1821
  case 27: {
1765
1822
  void (parameters.push(parseParam()));
@@ -1799,8 +1856,8 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
1799
1856
  }
1800
1857
  TokenStream__Expect_77B9EE56(stream, TokenKind.Arrow, "Expected \'->\' in match case");
1801
1858
  const body_2 = parseExprOrBlock();
1802
- const span_1 = mkSpanFrom(Ast_spanOfPattern(pat), Ast_spanOfExpr(body_2));
1803
- void (cases_2.push([pat, guard, body_2, span_1]));
1859
+ const span_4 = mkSpanFrom(Ast_spanOfPattern(pat), Ast_spanOfExpr(body_2));
1860
+ void (cases_2.push([pat, guard, body_2, span_4]));
1804
1861
  };
1805
1862
  if (TokenStream__Match_5CEB78CD(stream, TokenKind.Newline)) {
1806
1863
  while (TokenStream__Match_5CEB78CD(stream, TokenKind.Newline)) {
@@ -1825,30 +1882,30 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
1825
1882
  let doneCases_1 = false;
1826
1883
  while (!doneCases_1) {
1827
1884
  TokenStream__SkipNewlines(stream);
1828
- const matchValue_38 = TokenStream__Peek(stream).Kind;
1829
- let matchResult_6;
1830
- switch (matchValue_38.tag) {
1885
+ const matchValue_39 = TokenStream__Peek(stream).Kind;
1886
+ let matchResult_7;
1887
+ switch (matchValue_39.tag) {
1831
1888
  case 26: {
1832
- matchResult_6 = 0;
1889
+ matchResult_7 = 0;
1833
1890
  break;
1834
1891
  }
1835
1892
  case 3: {
1836
1893
  if (hasIndentedCaseBlock) {
1837
- matchResult_6 = 1;
1894
+ matchResult_7 = 1;
1838
1895
  }
1839
1896
  else {
1840
- matchResult_6 = 3;
1897
+ matchResult_7 = 3;
1841
1898
  }
1842
1899
  break;
1843
1900
  }
1844
1901
  case 2: {
1845
- matchResult_6 = 2;
1902
+ matchResult_7 = 2;
1846
1903
  break;
1847
1904
  }
1848
1905
  default:
1849
- matchResult_6 = 3;
1906
+ matchResult_7 = 3;
1850
1907
  }
1851
- switch (matchResult_6) {
1908
+ switch (matchResult_7) {
1852
1909
  case 0: {
1853
1910
  ensureAlignedCaseStart();
1854
1911
  parseCase_1();
@@ -1880,8 +1937,8 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
1880
1937
  let doneCases_2 = false;
1881
1938
  while (!doneCases_2) {
1882
1939
  TokenStream__SkipNewlines(stream);
1883
- const matchValue_39 = TokenStream__Peek(stream).Kind;
1884
- switch (matchValue_39.tag) {
1940
+ const matchValue_40 = TokenStream__Peek(stream).Kind;
1941
+ switch (matchValue_40.tag) {
1885
1942
  case 26: {
1886
1943
  parseCase_1();
1887
1944
  break;
@@ -1899,7 +1956,7 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
1899
1956
  return new Expr(/* EMatch */ 9, [expr_5, toList(cases_2), mkSpanFrom(matchTok.Span, Ast_spanOfExpr(expr_5))]);
1900
1957
  };
1901
1958
  const parseLetExpr = () => {
1902
- let matchValue_42;
1959
+ let matchValue_43;
1903
1960
  const letTok = TokenStream__Expect_77B9EE56(stream, TokenKind.Let, "Expected \'let\'");
1904
1961
  const isRec_1 = TokenStream__Match_5CEB78CD(stream, TokenKind.Rec);
1905
1962
  let patternInput_2;
@@ -1909,8 +1966,8 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
1909
1966
  }
1910
1967
  const nameTok_13 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'let\'");
1911
1968
  let name_15;
1912
- const matchValue_40 = nameTok_13.Kind;
1913
- name_15 = ((matchValue_40.tag === 4) ? matchValue_40.fields[0] : "");
1969
+ const matchValue_41 = nameTok_13.Kind;
1970
+ name_15 = ((matchValue_41.tag === 4) ? matchValue_41.fields[0] : "");
1914
1971
  const args_1 = parseParamsAligned();
1915
1972
  if (args_1.length === 0) {
1916
1973
  throw new ParseException(new ParseError("\'let rec\' requires at least one function argument", nameTok_13.Span));
@@ -1930,7 +1987,7 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
1930
1987
  }
1931
1988
  else {
1932
1989
  const nameTok_14 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'let\'");
1933
- patternInput_2 = [(matchValue_42 = nameTok_14.Kind, (matchValue_42.tag === 4) ? matchValue_42.fields[0] : ""), parseParamsAligned(), undefined, nameTok_14.Span];
1990
+ patternInput_2 = [(matchValue_43 = nameTok_14.Kind, (matchValue_43.tag === 4) ? matchValue_43.fields[0] : ""), parseParamsAligned(), undefined, nameTok_14.Span];
1934
1991
  }
1935
1992
  const tuplePatternOpt = patternInput_2[2];
1936
1993
  const bindingName = patternInput_2[0];
@@ -1961,8 +2018,8 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
1961
2018
  if (TokenStream__Match_5CEB78CD(stream, TokenKind.And)) {
1962
2019
  const nextNameTok = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'and\'");
1963
2020
  let nextName;
1964
- const matchValue_43 = nextNameTok.Kind;
1965
- nextName = ((matchValue_43.tag === 4) ? matchValue_43.fields[0] : "");
2021
+ const matchValue_44 = nextNameTok.Kind;
2022
+ nextName = ((matchValue_44.tag === 4) ? matchValue_44.fields[0] : "");
1966
2023
  const nextArgs = parseParamsAligned();
1967
2024
  if (nextArgs.length === 0) {
1968
2025
  throw new ParseException(new ParseError("\'let rec ... and ...\' requires function arguments for each binding", nextNameTok.Span));
@@ -1981,20 +2038,20 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
1981
2038
  doneBindings = true;
1982
2039
  }
1983
2040
  }
1984
- const matchValue_44 = TokenStream__Peek(stream).Kind;
1985
- let matchResult_7;
1986
- if (matchValue_44.tag === 4) {
1987
- if (matchValue_44.fields[0] === "in") {
1988
- matchResult_7 = 0;
2041
+ const matchValue_45 = TokenStream__Peek(stream).Kind;
2042
+ let matchResult_8;
2043
+ if (matchValue_45.tag === 4) {
2044
+ if (matchValue_45.fields[0] === "in") {
2045
+ matchResult_8 = 0;
1989
2046
  }
1990
2047
  else {
1991
- matchResult_7 = 1;
2048
+ matchResult_8 = 1;
1992
2049
  }
1993
2050
  }
1994
2051
  else {
1995
- matchResult_7 = 1;
2052
+ matchResult_8 = 1;
1996
2053
  }
1997
- switch (matchResult_7) {
2054
+ switch (matchResult_8) {
1998
2055
  case 0:
1999
2056
  throw new ParseException(new ParseError("\'in\' keyword is not supported", TokenStream__Peek(stream).Span));
2000
2057
  default: {
@@ -2016,20 +2073,20 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
2016
2073
  }
2017
2074
  }
2018
2075
  else {
2019
- const matchValue_46 = TokenStream__Peek(stream).Kind;
2020
- let matchResult_8;
2021
- if (matchValue_46.tag === 4) {
2022
- if (matchValue_46.fields[0] === "in") {
2023
- matchResult_8 = 0;
2076
+ const matchValue_47 = TokenStream__Peek(stream).Kind;
2077
+ let matchResult_9;
2078
+ if (matchValue_47.tag === 4) {
2079
+ if (matchValue_47.fields[0] === "in") {
2080
+ matchResult_9 = 0;
2024
2081
  }
2025
2082
  else {
2026
- matchResult_8 = 1;
2083
+ matchResult_9 = 1;
2027
2084
  }
2028
2085
  }
2029
2086
  else {
2030
- matchResult_8 = 1;
2087
+ matchResult_9 = 1;
2031
2088
  }
2032
- switch (matchResult_8) {
2089
+ switch (matchResult_9) {
2033
2090
  case 0:
2034
2091
  throw new ParseException(new ParseError("\'in\' keyword is not supported", TokenStream__Peek(stream).Span));
2035
2092
  default: {
@@ -2074,59 +2131,59 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
2074
2131
  let doneBlock = false;
2075
2132
  let blockStatementColumn = undefined;
2076
2133
  while (!doneBlock) {
2077
- let col, matchValue_50;
2134
+ let col, matchValue_51;
2078
2135
  TokenStream__SkipNewlines(stream);
2079
- const matchValue_48 = TokenStream__Peek(stream).Kind;
2080
- let matchResult_9;
2081
- switch (matchValue_48.tag) {
2136
+ const matchValue_49 = TokenStream__Peek(stream).Kind;
2137
+ let matchResult_10;
2138
+ switch (matchValue_49.tag) {
2082
2139
  case 3: {
2083
- matchResult_9 = 0;
2140
+ matchResult_10 = 0;
2084
2141
  break;
2085
2142
  }
2086
2143
  case 28:
2087
2144
  case 30:
2088
2145
  case 44: {
2089
- matchResult_9 = 1;
2146
+ matchResult_10 = 1;
2090
2147
  break;
2091
2148
  }
2092
2149
  case 0: {
2093
- matchResult_9 = 2;
2150
+ matchResult_10 = 2;
2094
2151
  break;
2095
2152
  }
2096
2153
  case 10: {
2097
- matchResult_9 = 3;
2154
+ matchResult_10 = 3;
2098
2155
  break;
2099
2156
  }
2100
2157
  case 39: {
2101
- matchResult_9 = 4;
2158
+ matchResult_10 = 4;
2102
2159
  break;
2103
2160
  }
2104
2161
  case 42: {
2105
- matchResult_9 = 6;
2162
+ matchResult_10 = 6;
2106
2163
  break;
2107
2164
  }
2108
2165
  case 38: {
2109
2166
  if (equals(TokenStream__PeekAt_Z524259A4(stream, 1).Kind, TokenKind.Import) ? true : equals(TokenStream__PeekAt_Z524259A4(stream, 1).Kind, TokenKind.Include)) {
2110
- matchResult_9 = 5;
2167
+ matchResult_10 = 5;
2111
2168
  }
2112
2169
  else {
2113
- matchResult_9 = 8;
2170
+ matchResult_10 = 8;
2114
2171
  }
2115
2172
  break;
2116
2173
  }
2117
2174
  case 29: {
2118
2175
  if (equals(TokenStream__PeekAt_Z524259A4(stream, 1).Kind, TokenKind.Less)) {
2119
- matchResult_9 = 7;
2176
+ matchResult_10 = 7;
2120
2177
  }
2121
2178
  else {
2122
- matchResult_9 = 8;
2179
+ matchResult_10 = 8;
2123
2180
  }
2124
2181
  break;
2125
2182
  }
2126
2183
  default:
2127
- matchResult_9 = 8;
2184
+ matchResult_10 = 8;
2128
2185
  }
2129
- switch (matchResult_9) {
2186
+ switch (matchResult_10) {
2130
2187
  case 0: {
2131
2188
  TokenStream__Next(stream);
2132
2189
  TokenStream__SkipNewlines(stream);
@@ -2134,8 +2191,8 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
2134
2191
  findNextNonLayout:
2135
2192
  while (true) {
2136
2193
  const offset_1 = offset_1_mut;
2137
- const matchValue_49 = TokenStream__PeekAt_Z524259A4(stream, offset_1).Kind;
2138
- switch (matchValue_49.tag) {
2194
+ const matchValue_50 = TokenStream__PeekAt_Z524259A4(stream, offset_1).Kind;
2195
+ switch (matchValue_50.tag) {
2139
2196
  case 1:
2140
2197
  case 2:
2141
2198
  case 3: {
@@ -2150,7 +2207,7 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
2150
2207
  };
2151
2208
  const nextSignificant = findNextNonLayout(0);
2152
2209
  TokenStream__Peek(stream);
2153
- if (!((blockStatementColumn == null) ? false : ((col = (blockStatementColumn | 0), (matchValue_50 = nextSignificant.Kind, (matchValue_50.tag === 0) ? false : ((matchValue_50.tag === 3) ? false : ((matchValue_50.tag === 28) ? false : ((matchValue_50.tag === 30) ? false : ((matchValue_50.tag === 44) ? false : (nextSignificant.Span.Start.Column >= col)))))))))) {
2210
+ if (!((blockStatementColumn == null) ? false : ((col = (blockStatementColumn | 0), (matchValue_51 = nextSignificant.Kind, (matchValue_51.tag === 0) ? false : ((matchValue_51.tag === 3) ? false : ((matchValue_51.tag === 28) ? false : ((matchValue_51.tag === 30) ? false : ((matchValue_51.tag === 44) ? false : (nextSignificant.Span.Start.Column >= col)))))))))) {
2154
2211
  doneBlock = true;
2155
2212
  }
2156
2213
  break;
@@ -2252,7 +2309,7 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
2252
2309
  return desugar(toList(statements));
2253
2310
  };
2254
2311
  const parseLetStmt = (isExported) => {
2255
- let matchValue_53;
2312
+ let matchValue_54;
2256
2313
  const letTok_1 = TokenStream__Next(stream);
2257
2314
  const isRec_3 = TokenStream__Match_5CEB78CD(stream, TokenKind.Rec);
2258
2315
  let patternInput_3;
@@ -2262,8 +2319,8 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
2262
2319
  }
2263
2320
  const nameTok_15 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'let\'");
2264
2321
  let name_18;
2265
- const matchValue_51 = nameTok_15.Kind;
2266
- name_18 = ((matchValue_51.tag === 4) ? matchValue_51.fields[0] : "");
2322
+ const matchValue_52 = nameTok_15.Kind;
2323
+ name_18 = ((matchValue_52.tag === 4) ? matchValue_52.fields[0] : "");
2267
2324
  const args_4 = parseParamsAligned();
2268
2325
  if (args_4.length === 0) {
2269
2326
  throw new ParseException(new ParseError("\'let rec\' requires at least one function argument", nameTok_15.Span));
@@ -2286,7 +2343,7 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
2286
2343
  }
2287
2344
  else {
2288
2345
  const nameTok_16 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'let\'");
2289
- patternInput_3 = [(matchValue_53 = nameTok_16.Kind, (matchValue_53.tag === 4) ? matchValue_53.fields[0] : ""), parseParamsAligned(), undefined, nameTok_16.Span];
2346
+ patternInput_3 = [(matchValue_54 = nameTok_16.Kind, (matchValue_54.tag === 4) ? matchValue_54.fields[0] : ""), parseParamsAligned(), undefined, nameTok_16.Span];
2290
2347
  }
2291
2348
  const tuplePatternOpt_1 = patternInput_3[2];
2292
2349
  const bindingName_1 = patternInput_3[0];
@@ -2317,8 +2374,8 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
2317
2374
  if (TokenStream__Match_5CEB78CD(stream, TokenKind.And)) {
2318
2375
  const nextNameTok_1 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'and\'");
2319
2376
  let nextName_1;
2320
- const matchValue_54 = nextNameTok_1.Kind;
2321
- nextName_1 = ((matchValue_54.tag === 4) ? matchValue_54.fields[0] : "");
2377
+ const matchValue_55 = nextNameTok_1.Kind;
2378
+ nextName_1 = ((matchValue_55.tag === 4) ? matchValue_55.fields[0] : "");
2322
2379
  const nextArgs_1 = parseParamsAligned();
2323
2380
  if (nextArgs_1.length === 0) {
2324
2381
  throw new ParseException(new ParseError("\'let rec ... and ...\' requires function arguments for each binding", nextNameTok_1.Span));
@@ -2362,30 +2419,30 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
2362
2419
  TokenStream__Expect_77B9EE56(stream, TokenKind.Less, "Expected \'<\' in attribute");
2363
2420
  const nameTok_17 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected attribute name");
2364
2421
  let name_20;
2365
- const matchValue_55 = nameTok_17.Kind;
2366
- name_20 = ((matchValue_55.tag === 4) ? matchValue_55.fields[0] : "");
2422
+ const matchValue_56 = nameTok_17.Kind;
2423
+ name_20 = ((matchValue_56.tag === 4) ? matchValue_56.fields[0] : "");
2367
2424
  const arguments$ = [];
2368
2425
  if (TokenStream__Match_5CEB78CD(stream, TokenKind.LParen)) {
2369
2426
  let doneArguments = false;
2370
2427
  while (!doneArguments) {
2371
2428
  const argument = TokenStream__Next(stream);
2372
- const matchValue_56 = argument.Kind;
2373
- let matchResult_10, value_83;
2374
- switch (matchValue_56.tag) {
2429
+ const matchValue_57 = argument.Kind;
2430
+ let matchResult_11, value_83;
2431
+ switch (matchValue_57.tag) {
2375
2432
  case 7: {
2376
- matchResult_10 = 0;
2377
- value_83 = matchValue_56.fields[0];
2433
+ matchResult_11 = 0;
2434
+ value_83 = matchValue_57.fields[0];
2378
2435
  break;
2379
2436
  }
2380
2437
  case 4: {
2381
- matchResult_10 = 0;
2382
- value_83 = matchValue_56.fields[0];
2438
+ matchResult_11 = 0;
2439
+ value_83 = matchValue_57.fields[0];
2383
2440
  break;
2384
2441
  }
2385
2442
  default:
2386
- matchResult_10 = 1;
2443
+ matchResult_11 = 1;
2387
2444
  }
2388
- switch (matchResult_10) {
2445
+ switch (matchResult_11) {
2389
2446
  case 0: {
2390
2447
  void (arguments$.push(value_83));
2391
2448
  break;
@@ -2411,39 +2468,39 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
2411
2468
  const letToken = TokenStream__Expect_77B9EE56(stream, TokenKind.Let, "Expected \'let\' after Import attribute");
2412
2469
  const nameToken = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected imported binding name");
2413
2470
  let name_21;
2414
- const matchValue_57 = nameToken.Kind;
2415
- name_21 = ((matchValue_57.tag === 4) ? matchValue_57.fields[0] : "");
2471
+ const matchValue_58 = nameToken.Kind;
2472
+ name_21 = ((matchValue_58.tag === 4) ? matchValue_58.fields[0] : "");
2416
2473
  TokenStream__Expect_77B9EE56(stream, TokenKind.Colon, "Imported binding requires a complete type signature");
2417
2474
  const signature = parseTypeRef();
2418
2475
  if (equals(TokenStream__Peek(stream).Kind, TokenKind.Equals)) {
2419
2476
  throw new ParseException(new ParseError("Imported bindings must not have a body", TokenStream__Peek(stream).Span));
2420
2477
  }
2421
- const matchValue_58 = attribute_1.Arguments;
2422
- let matchResult_11, memberName_3, modulePath_3;
2423
- if (!isEmpty(matchValue_58)) {
2424
- if (!isEmpty(tail_1(matchValue_58))) {
2425
- if (isEmpty(tail_1(tail_1(matchValue_58)))) {
2426
- if (!isNullOrWhiteSpace(head_1(matchValue_58)) && !isNullOrWhiteSpace(head_1(tail_1(matchValue_58)))) {
2427
- matchResult_11 = 0;
2428
- memberName_3 = head_1(tail_1(matchValue_58));
2429
- modulePath_3 = head_1(matchValue_58);
2478
+ const matchValue_59 = attribute_1.Arguments;
2479
+ let matchResult_12, memberName_3, modulePath_3;
2480
+ if (!isEmpty(matchValue_59)) {
2481
+ if (!isEmpty(tail_1(matchValue_59))) {
2482
+ if (isEmpty(tail_1(tail_1(matchValue_59)))) {
2483
+ if (!isNullOrWhiteSpace(head_1(matchValue_59)) && !isNullOrWhiteSpace(head_1(tail_1(matchValue_59)))) {
2484
+ matchResult_12 = 0;
2485
+ memberName_3 = head_1(tail_1(matchValue_59));
2486
+ modulePath_3 = head_1(matchValue_59);
2430
2487
  }
2431
2488
  else {
2432
- matchResult_11 = 1;
2489
+ matchResult_12 = 1;
2433
2490
  }
2434
2491
  }
2435
2492
  else {
2436
- matchResult_11 = 1;
2493
+ matchResult_12 = 1;
2437
2494
  }
2438
2495
  }
2439
2496
  else {
2440
- matchResult_11 = 1;
2497
+ matchResult_12 = 1;
2441
2498
  }
2442
2499
  }
2443
2500
  else {
2444
- matchResult_11 = 1;
2501
+ matchResult_12 = 1;
2445
2502
  }
2446
- switch (matchResult_11) {
2503
+ switch (matchResult_12) {
2447
2504
  case 0:
2448
2505
  return new Stmt(/* SBackendImport */ 5, [name_21, signature, new BackendImport(modulePath_3, memberName_3, attribute_1.Span), mkSpanFrom(letToken.Span, nameToken.Span)]);
2449
2506
  default:
@@ -2461,7 +2518,7 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
2461
2518
  }
2462
2519
  };
2463
2520
  const parseAttributedStmt = () => {
2464
- let matchValue_63;
2521
+ let matchValue_64;
2465
2522
  let hasAttributes = false;
2466
2523
  let backendImport_1 = undefined;
2467
2524
  const structuredAttributes = [];
@@ -2470,8 +2527,8 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
2470
2527
  if (equals(TokenStream__Peek(stream).Kind, TokenKind.LBracket) && equals(TokenStream__PeekAt_Z524259A4(stream, 1).Kind, TokenKind.Less)) {
2471
2528
  hasAttributes = true;
2472
2529
  const attribute_2 = parseAttribute();
2473
- const matchValue_59 = attribute_2.Name;
2474
- switch (matchValue_59) {
2530
+ const matchValue_60 = attribute_2.Name;
2531
+ switch (matchValue_60) {
2475
2532
  case "export":
2476
2533
  case "Export": {
2477
2534
  throw new ParseException(new ParseError("Unexpected attribute", attribute_2.Span));
@@ -2494,15 +2551,15 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
2494
2551
  }
2495
2552
  }
2496
2553
  let statement;
2497
- const matchValue_60 = TokenStream__Peek(stream).Kind;
2498
- switch (matchValue_60.tag) {
2554
+ const matchValue_61 = TokenStream__Peek(stream).Kind;
2555
+ switch (matchValue_61.tag) {
2499
2556
  case 38: {
2500
2557
  if (hasAttributes) {
2501
2558
  throw new ParseException(new ParseError("Attributes are not supported on \'import\' directives", TokenStream__Peek(stream).Span));
2502
2559
  }
2503
2560
  const hashTok = TokenStream__Next(stream);
2504
- const matchValue_61 = TokenStream__Next(stream).Kind;
2505
- switch (matchValue_61.tag) {
2561
+ const matchValue_62 = TokenStream__Next(stream).Kind;
2562
+ switch (matchValue_62.tag) {
2506
2563
  case 41: {
2507
2564
  throw new ParseException(new ParseError("\'#include\' was removed in 0.32.0; use \'import \"file.fss\" as Alias\'", hashTok.Span));
2508
2565
  break;
@@ -2522,12 +2579,12 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
2522
2579
  }
2523
2580
  const importTok = TokenStream__Next(stream);
2524
2581
  const pathTok = TokenStream__Next(stream);
2525
- const matchValue_62 = pathTok.Kind;
2526
- if (matchValue_62.tag === 7) {
2527
- if (!isNullOrWhiteSpace(matchValue_62.fields[0])) {
2582
+ const matchValue_63 = pathTok.Kind;
2583
+ if (matchValue_63.tag === 7) {
2584
+ if (!isNullOrWhiteSpace(matchValue_63.fields[0])) {
2528
2585
  TokenStream__Expect_77B9EE56(stream, TokenKind.As, "Expected \'as\' in import directive. Use: import \"file.fss\" as Alias");
2529
2586
  const aliasTok = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected module alias after \'as\'");
2530
- statement = (new Stmt(/* SImport */ 1, [(matchValue_63 = aliasTok.Kind, (matchValue_63.tag === 4) ? matchValue_63.fields[0] : ""), matchValue_62.fields[0], mkSpanFrom(importTok.Span, aliasTok.Span)]));
2587
+ statement = (new Stmt(/* SImport */ 1, [(matchValue_64 = aliasTok.Kind, (matchValue_64.tag === 4) ? matchValue_64.fields[0] : ""), matchValue_63.fields[0], mkSpanFrom(importTok.Span, aliasTok.Span)]));
2531
2588
  }
2532
2589
  else {
2533
2590
  throw new ParseException(new ParseError("Import path cannot be empty", pathTok.Span));
@@ -2568,8 +2625,8 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
2568
2625
  const program = [];
2569
2626
  TokenStream__SkipNewlines(stream);
2570
2627
  while (!TokenStream__get_AtEnd(stream)) {
2571
- const matchValue_64 = TokenStream__Peek(stream).Kind;
2572
- switch (matchValue_64.tag) {
2628
+ const matchValue_65 = TokenStream__Peek(stream).Kind;
2629
+ switch (matchValue_65.tag) {
2573
2630
  case 0: {
2574
2631
  TokenStream__Next(stream);
2575
2632
  break;
@@ -2589,7 +2646,22 @@ function parseProgramWithSourceNameAndOrigin(sourceName, startLine, startColumn,
2589
2646
  }
2590
2647
 
2591
2648
  export function parseProgramWithSourceName(sourceName, src) {
2592
- return parseProgramWithSourceNameAndOrigin(sourceName, 1, 1, src);
2649
+ return parseProgramWithSourceNameAndOrigin(undefined, sourceName, 1, 1, src);
2650
+ }
2651
+
2652
+ /**
2653
+ * Records the identifier spans of declared and constructed nominal record fields.
2654
+ */
2655
+ export function parseProgramWithRecordFieldLabels(sourceName, src) {
2656
+ const labels = new Dictionary([], {
2657
+ Equals: equals,
2658
+ GetHashCode: (x) => (safeHash(x) | 0),
2659
+ });
2660
+ return [parseProgramWithSourceNameAndOrigin((span, fields) => {
2661
+ labels.set(span, fields);
2662
+ }, sourceName, 1, 1, src), ofSeq_1(map_1((pair) => [pair[0], pair[1]], labels), {
2663
+ Compare: (x_1, y_1) => (compare(x_1, y_1) | 0),
2664
+ })];
2593
2665
  }
2594
2666
 
2595
2667
  export function parseProgram(src) {