@magnusopera/fscript 0.77.1 → 0.79.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/FScript.Language/Ast.js +2 -2
  2. package/dist/FScript.Language/BuiltinFunctions.js +68 -67
  3. package/dist/FScript.Language/BuiltinSignatures.js +7 -7
  4. package/dist/FScript.Language/BuiltinTypes.js +3 -3
  5. package/dist/FScript.Language/Error.js +2 -2
  6. package/dist/FScript.Language/Eval.js +305 -213
  7. package/dist/FScript.Language/IncludeResolver.js +97 -79
  8. package/dist/FScript.Language/Interactive.js +149 -0
  9. package/dist/FScript.Language/Lexer.js +77 -77
  10. package/dist/FScript.Language/Parser.js +274 -272
  11. package/dist/FScript.Language/Pretty.js +4 -4
  12. package/dist/FScript.Language/Span.js +2 -2
  13. package/dist/FScript.Language/Token.js +59 -2
  14. package/dist/FScript.Language/TypeInfer.js +704 -379
  15. package/dist/FScript.Language/Types.js +98 -27
  16. package/dist/FScript.Language/Value.js +3 -2
  17. package/dist/Library.js +91 -79
  18. package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Array.js +36 -35
  19. package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Async.js +52 -23
  20. package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/AsyncBuilder.js +23 -2
  21. package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/BigInt.js +33 -32
  22. package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/BitConverter.js +2 -2
  23. package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/CHANGELOG.md +80 -1
  24. package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Date.js +8 -15
  25. package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/DateOffset.js +8 -17
  26. package/dist/fable_modules/fable-library-js.5.13.0/Directory.js +11 -0
  27. package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Double.js +8 -2
  28. package/dist/fable_modules/fable-library-js.5.13.0/Environment.js +3 -0
  29. package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Event.js +10 -1
  30. package/dist/fable_modules/fable-library-js.5.13.0/File.js +27 -0
  31. package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/List.js +35 -21
  32. package/dist/fable_modules/fable-library-js.5.13.0/Long.js +38 -0
  33. package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/MailboxProcessor.js +11 -5
  34. package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Map.js +8 -4
  35. package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/MutableMap.js +2 -2
  36. package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/MutableSet.js +1 -1
  37. package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Observable.js +5 -3
  38. package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Option.js +1 -18
  39. package/dist/fable_modules/fable-library-js.5.13.0/Path.js +31 -0
  40. package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Reflection.js +13 -3
  41. package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/RegExp.js +53 -24
  42. package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Seq.js +109 -22
  43. package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Set.js +16 -3
  44. package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/String.js +28 -1
  45. package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/System.js +15 -9
  46. package/dist/fable_modules/fable-library-js.5.13.0/Task.js +27 -0
  47. package/dist/fable_modules/fable-library-js.5.13.0/TaskBuilder.js +72 -0
  48. package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Types.js +12 -12
  49. package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Util.js +15 -3
  50. package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/package.json +1 -1
  51. package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/quotation.js +25 -8
  52. package/dist/fable_modules/project_cracked.json +1 -1
  53. package/package.json +2 -2
  54. package/dist/fable_modules/fable-library-js.5.2.0/Long.js +0 -47
  55. /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Boolean.js +0 -0
  56. /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Char.js +0 -0
  57. /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Choice.js +0 -0
  58. /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/CollectionUtil.js +0 -0
  59. /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/ConditionalWeakTable.js +0 -0
  60. /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/DateOnly.js +0 -0
  61. /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Decimal.js +0 -0
  62. /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Encoding.js +0 -0
  63. /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/FSharp.Collections.js +0 -0
  64. /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/FSharp.Core.CompilerServices.js +0 -0
  65. /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/FSharp.Core.js +0 -0
  66. /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Global.js +0 -0
  67. /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Guid.js +0 -0
  68. /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Int32.js +0 -0
  69. /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/MapUtil.js +0 -0
  70. /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Native.js +0 -0
  71. /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Numeric.js +0 -0
  72. /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/README.md +0 -0
  73. /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Random.js +0 -0
  74. /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Range.js +0 -0
  75. /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Result.js +0 -0
  76. /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Seq2.js +0 -0
  77. /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/System.Collections.Generic.js +0 -0
  78. /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/System.Text.js +0 -0
  79. /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/TimeOnly.js +0 -0
  80. /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/TimeSpan.js +0 -0
  81. /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Timer.js +0 -0
  82. /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Unicode.13.0.0.js +0 -0
  83. /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Uri.js +0 -0
  84. /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/big.d.ts +0 -0
  85. /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/lib/big.js +0 -0
@@ -1,19 +1,19 @@
1
1
 
2
2
  import { Span_$reflection, Span, Position } from "./Span.js";
3
- import { iterate as iterate_2, FSharpMap__Add, FSharpMap__ContainsKey, values, keys, FSharpMap__TryFind, ofList, toList, FSharpMap__get_Item, FSharpMap__get_Keys, add, fold as fold_1, remove, map as map_1, tryFind, empty } from "../fable_modules/fable-library-js.5.2.0/Map.js";
4
- import { disposeSafe, getEnumerator, stringHash, compareArrays, equals, comparePrimitives } from "../fable_modules/fable-library-js.5.2.0/Util.js";
5
- import { Types_generalize, Type_$reflection, Types_freshVar, Types_typeToString, Types_ftvType, Scheme, Type } from "./Types.js";
6
- import { tryFind as tryFind_1, indexed, ofArray, collect, append, iterate, reverse, tryFindIndex, choose, tail as tail_2, cons, head as head_1, isEmpty, empty as empty_2, singleton, zip, length, fold, map } from "../fable_modules/fable-library-js.5.2.0/List.js";
7
- import { toList as toList_2, add as add_1, empty as empty_1, isSubset, ofSeq, FSharpSet__Add, FSharpSet__Contains, contains } from "../fable_modules/fable-library-js.5.2.0/Set.js";
3
+ import { iterate as iterate_2, FSharpMap__Add, values, FSharpMap__get_Keys, keys, FSharpMap__TryFind, ofList, toList, FSharpMap__get_Item, FSharpMap__ContainsKey, FSharpMap__get_Count, exists as exists_1, add, fold as fold_1, remove, map as map_1, tryFind, isEmpty, empty } from "../fable_modules/fable-library-js.5.13.0/Map.js";
4
+ import { disposeSafe, getEnumerator, stringHash, compareArrays, equals, comparePrimitives } from "../fable_modules/fable-library-js.5.13.0/Util.js";
5
+ import { Types_generalize, Types_freshNumeric, Type_$reflection, Types_freshVar, Types_typeToString, Scheme, Type } from "./Types.js";
6
+ import { tryFind as tryFind_1, indexed, ofArray, collect, append, iterate, reverse, tryFindIndex, choose, tail as tail_2, cons, head as head_1, isEmpty as isEmpty_1, empty as empty_2, singleton, zip, length, exists, fold, map } from "../fable_modules/fable-library-js.5.13.0/List.js";
7
+ import { toList as toList_2, ofSeq, contains, add as add_1, empty as empty_1, FSharpSet__Add, FSharpSet__Contains } from "../fable_modules/fable-library-js.5.13.0/Set.js";
8
8
  import { TypeException, TypeError$ } from "./Error.js";
9
- import { endsWith, split, join, concat, isNullOrWhiteSpace, printf, toText } from "../fable_modules/fable-library-js.5.2.0/String.js";
10
- import { toArray, map as map_3, defaultArg } from "../fable_modules/fable-library-js.5.2.0/Option.js";
11
- import { Union, Record } from "../fable_modules/fable-library-js.5.2.0/Types.js";
9
+ import { endsWith, split, join, concat, isNullOrWhiteSpace, printf, toText } from "../fable_modules/fable-library-js.5.13.0/String.js";
10
+ import { defaultArg } from "../fable_modules/fable-library-js.5.13.0/Option.js";
11
+ import { Union, Record } from "../fable_modules/fable-library-js.5.13.0/Types.js";
12
12
  import { Expr, Ast_spanOfPattern, Ast_spanOfExpr, Pattern_$reflection, TypeDef_$reflection, Expr_$reflection } from "./Ast.js";
13
- import { option_type, array_type, union_type, list_type, tuple_type, class_type, bool_type, string_type, record_type } from "../fable_modules/fable-library-js.5.2.0/Reflection.js";
14
- import { foldBack, iterate as iterate_1, filter, map as map_2, toList as toList_1 } from "../fable_modules/fable-library-js.5.2.0/Seq.js";
15
- import { last, item as item_2 } from "../fable_modules/fable-library-js.5.2.0/Array.js";
16
- import { distinct } from "../fable_modules/fable-library-js.5.2.0/Seq2.js";
13
+ import { option_type, array_type, union_type, list_type, tuple_type, class_type, bool_type, string_type, record_type } from "../fable_modules/fable-library-js.5.13.0/Reflection.js";
14
+ import { foldBack, iterate as iterate_1, filter, map as map_2, toList as toList_1 } from "../fable_modules/fable-library-js.5.13.0/Seq.js";
15
+ import { last, item as item_2 } from "../fable_modules/fable-library-js.5.13.0/Array.js";
16
+ import { distinct } from "../fable_modules/fable-library-js.5.13.0/Seq2.js";
17
17
  import { builtinReservedNames, builtinSchemes } from "./BuiltinSignatures.js";
18
18
  import { typeDefs as typeDefs_1 } from "./BuiltinTypes.js";
19
19
 
@@ -23,58 +23,218 @@ const emptySubst = empty({
23
23
  Compare: (x, y) => (comparePrimitives(x, y) | 0),
24
24
  });
25
25
 
26
- function applyType(s_mut, t_mut) {
27
- applyType:
28
- while (true) {
29
- const s = s_mut, t = t_mut;
30
- switch (t.tag) {
31
- case 15: {
32
- const matchValue = tryFind(t.fields[0], s);
33
- if (matchValue == null) {
34
- return t;
26
+ function applyType(s, t) {
27
+ if (isEmpty(s)) {
28
+ return t;
29
+ }
30
+ else {
31
+ const apply = (current_mut) => {
32
+ apply:
33
+ while (true) {
34
+ const current = current_mut;
35
+ let matchResult, v;
36
+ switch (current.tag) {
37
+ case 15: {
38
+ matchResult = 0;
39
+ v = current.fields[0];
40
+ break;
41
+ }
42
+ case 16: {
43
+ matchResult = 0;
44
+ v = current.fields[0];
45
+ break;
46
+ }
47
+ case 5: {
48
+ matchResult = 1;
49
+ break;
50
+ }
51
+ case 6: {
52
+ matchResult = 2;
53
+ break;
54
+ }
55
+ case 7: {
56
+ matchResult = 3;
57
+ break;
58
+ }
59
+ case 8: {
60
+ matchResult = 4;
61
+ break;
62
+ }
63
+ case 9: {
64
+ matchResult = 5;
65
+ break;
66
+ }
67
+ case 10: {
68
+ matchResult = 6;
69
+ break;
70
+ }
71
+ case 11: {
72
+ matchResult = 7;
73
+ break;
74
+ }
75
+ default:
76
+ matchResult = 8;
35
77
  }
36
- else {
37
- s_mut = s;
38
- t_mut = matchValue;
39
- continue applyType;
78
+ switch (matchResult) {
79
+ case 0: {
80
+ const matchValue = tryFind(v, s);
81
+ if (matchValue == null) {
82
+ return current;
83
+ }
84
+ else if (!equals(matchValue, current)) {
85
+ const mapped_1 = matchValue;
86
+ current_mut = mapped_1;
87
+ continue apply;
88
+ }
89
+ else {
90
+ return current;
91
+ }
92
+ }
93
+ case 1:
94
+ return new Type(/* TList */ 5, [apply(current.fields[0])]);
95
+ case 2:
96
+ return new Type(/* TTask */ 6, [apply(current.fields[0])]);
97
+ case 3:
98
+ return new Type(/* TTuple */ 7, [map(apply, current.fields[0])]);
99
+ case 4:
100
+ return new Type(/* TRecord */ 8, [map_1((_arg, t1_2) => apply(t1_2), current.fields[0])]);
101
+ case 5:
102
+ return new Type(/* TMap */ 9, [apply(current.fields[0]), apply(current.fields[1])]);
103
+ case 6:
104
+ return new Type(/* TOption */ 10, [apply(current.fields[0])]);
105
+ case 7:
106
+ return new Type(/* TFun */ 11, [apply(current.fields[0]), apply(current.fields[1])]);
107
+ default:
108
+ return current;
40
109
  }
110
+ break;
41
111
  }
42
- case 5:
43
- return new Type(5, [applyType(s, t.fields[0])]);
44
- case 6:
45
- return new Type(6, [applyType(s, t.fields[0])]);
46
- case 7:
47
- return new Type(7, [map((t_1) => applyType(s, t_1), t.fields[0])]);
48
- case 8:
49
- return new Type(8, [map_1((_arg, t1_2) => applyType(s, t1_2), t.fields[0])]);
50
- case 9:
51
- return new Type(9, [applyType(s, t.fields[0]), applyType(s, t.fields[1])]);
52
- case 10:
53
- return new Type(10, [applyType(s, t.fields[0])]);
54
- case 11:
55
- return new Type(11, [applyType(s, t.fields[0]), applyType(s, t.fields[1])]);
56
- default:
57
- return t;
58
- }
59
- break;
112
+ };
113
+ return apply(t);
60
114
  }
61
115
  }
62
116
 
63
- function applyScheme(s, _arg) {
64
- const vars = _arg.fields[0];
65
- return new Scheme(vars, applyType(fold((acc, v) => remove(v, acc), s, vars), _arg.fields[1]));
117
+ function applyScheme(s, scheme) {
118
+ const scheme_1 = scheme;
119
+ const vars = scheme_1.fields[0];
120
+ if (isEmpty(s)) {
121
+ return scheme_1;
122
+ }
123
+ else {
124
+ return new Scheme(vars, applyType(fold((acc, v) => remove(v, acc), s, vars), scheme_1.fields[1]));
125
+ }
66
126
  }
67
127
 
68
128
  function applyEnv(s, env) {
69
- return map_1((_arg, sc) => applyScheme(s, sc), env);
129
+ if (isEmpty(s)) {
130
+ return env;
131
+ }
132
+ else {
133
+ return map_1((_arg, sc) => applyScheme(s, sc), env);
134
+ }
70
135
  }
71
136
 
72
137
  function compose(s1, s2) {
73
- return fold_1((acc, k, v) => add(k, v, acc), s1, map_1((_arg, t) => applyType(s1, t), s2));
138
+ if (isEmpty(s1)) {
139
+ return s2;
140
+ }
141
+ else if (isEmpty(s2)) {
142
+ return s1;
143
+ }
144
+ else {
145
+ return fold_1((acc, k, v) => add(k, v, acc), s1, map_1((_arg, t) => applyType(s1, t), s2));
146
+ }
74
147
  }
75
148
 
76
149
  function occurs(v, t) {
77
- return contains(v, Types_ftvType(t));
150
+ const loop = (current_mut) => {
151
+ loop:
152
+ while (true) {
153
+ const current = current_mut;
154
+ let matchResult, currentVar, item, keyType, valueType;
155
+ switch (current.tag) {
156
+ case 7: {
157
+ matchResult = 2;
158
+ break;
159
+ }
160
+ case 8: {
161
+ matchResult = 3;
162
+ break;
163
+ }
164
+ case 0:
165
+ case 1:
166
+ case 2:
167
+ case 3:
168
+ case 4:
169
+ case 12:
170
+ case 13:
171
+ case 14: {
172
+ matchResult = 5;
173
+ break;
174
+ }
175
+ case 16: {
176
+ matchResult = 0;
177
+ currentVar = current.fields[0];
178
+ break;
179
+ }
180
+ case 5: {
181
+ matchResult = 1;
182
+ item = current.fields[0];
183
+ break;
184
+ }
185
+ case 6: {
186
+ matchResult = 1;
187
+ item = current.fields[0];
188
+ break;
189
+ }
190
+ case 10: {
191
+ matchResult = 1;
192
+ item = current.fields[0];
193
+ break;
194
+ }
195
+ case 9: {
196
+ matchResult = 4;
197
+ keyType = current.fields[0];
198
+ valueType = current.fields[1];
199
+ break;
200
+ }
201
+ case 11: {
202
+ matchResult = 4;
203
+ keyType = current.fields[0];
204
+ valueType = current.fields[1];
205
+ break;
206
+ }
207
+ default: {
208
+ matchResult = 0;
209
+ currentVar = current.fields[0];
210
+ }
211
+ }
212
+ switch (matchResult) {
213
+ case 0:
214
+ return currentVar === v;
215
+ case 1: {
216
+ current_mut = item;
217
+ continue loop;
218
+ }
219
+ case 2:
220
+ return exists(loop, current.fields[0]);
221
+ case 3:
222
+ return exists_1((_arg, fieldType) => loop(fieldType), current.fields[0]);
223
+ case 4:
224
+ if (loop(keyType)) {
225
+ return true;
226
+ }
227
+ else {
228
+ current_mut = valueType;
229
+ continue loop;
230
+ }
231
+ default:
232
+ return false;
233
+ }
234
+ break;
235
+ }
236
+ };
237
+ return loop(t);
78
238
  }
79
239
 
80
240
  function unify(typeDefs, t1, t2, span) {
@@ -82,13 +242,13 @@ function unify(typeDefs, t1, t2, span) {
82
242
  uni:
83
243
  while (true) {
84
244
  const seen = seen_mut, a = a_mut, b = b_mut;
85
- let arg, arg_1, arg_2, arg_3, arg_4, arg_5;
245
+ let arg, arg_1, arg_2, arg_3, arg_4, arg_5, arg_6;
86
246
  if (FSharpSet__Contains(seen, [a, b]) ? true : FSharpSet__Contains(seen, [b, a])) {
87
247
  return emptySubst;
88
248
  }
89
249
  else {
90
250
  const seen$0027 = FSharpSet__Add(seen, [a, b]);
91
- let matchResult, x_1, y_1, x_2, y_2, x_3, y_3, xs, ys, xf, yf, kx, ky, vx, vy, x_7, y_7, a1, a2, b1, b2, t, v, name_1, t_1, name_2, t_2;
251
+ let matchResult, x_1, y_1, x_2, y_2, x_3, y_3, xs, ys, xf, yf, kx, ky, vx, vy, x_5, y_5, a1, a2, b1, b2, t, v, name_2, t_1, name_3, t_2, v_1, w, concrete, v_2, other_4;
92
252
  switch (a.tag) {
93
253
  case 0: {
94
254
  switch (b.tag) {
@@ -104,12 +264,17 @@ function unify(typeDefs, t1, t2, span) {
104
264
  }
105
265
  case 12: {
106
266
  matchResult = 11;
107
- name_2 = b.fields[0];
267
+ name_3 = b.fields[0];
108
268
  t_2 = a;
109
269
  break;
110
270
  }
271
+ case 16: {
272
+ matchResult = 14;
273
+ other_4 = a;
274
+ break;
275
+ }
111
276
  default:
112
- matchResult = 12;
277
+ matchResult = 15;
113
278
  }
114
279
  break;
115
280
  }
@@ -127,12 +292,18 @@ function unify(typeDefs, t1, t2, span) {
127
292
  }
128
293
  case 12: {
129
294
  matchResult = 11;
130
- name_2 = b.fields[0];
295
+ name_3 = b.fields[0];
131
296
  t_2 = a;
132
297
  break;
133
298
  }
299
+ case 16: {
300
+ matchResult = 13;
301
+ concrete = a;
302
+ v_2 = b.fields[0];
303
+ break;
304
+ }
134
305
  default:
135
- matchResult = 12;
306
+ matchResult = 15;
136
307
  }
137
308
  break;
138
309
  }
@@ -150,12 +321,18 @@ function unify(typeDefs, t1, t2, span) {
150
321
  }
151
322
  case 12: {
152
323
  matchResult = 11;
153
- name_2 = b.fields[0];
324
+ name_3 = b.fields[0];
154
325
  t_2 = a;
155
326
  break;
156
327
  }
328
+ case 16: {
329
+ matchResult = 13;
330
+ concrete = a;
331
+ v_2 = b.fields[0];
332
+ break;
333
+ }
157
334
  default:
158
- matchResult = 12;
335
+ matchResult = 15;
159
336
  }
160
337
  break;
161
338
  }
@@ -173,12 +350,17 @@ function unify(typeDefs, t1, t2, span) {
173
350
  }
174
351
  case 12: {
175
352
  matchResult = 11;
176
- name_2 = b.fields[0];
353
+ name_3 = b.fields[0];
177
354
  t_2 = a;
178
355
  break;
179
356
  }
357
+ case 16: {
358
+ matchResult = 14;
359
+ other_4 = a;
360
+ break;
361
+ }
180
362
  default:
181
- matchResult = 12;
363
+ matchResult = 15;
182
364
  }
183
365
  break;
184
366
  }
@@ -196,12 +378,17 @@ function unify(typeDefs, t1, t2, span) {
196
378
  }
197
379
  case 12: {
198
380
  matchResult = 11;
199
- name_2 = b.fields[0];
381
+ name_3 = b.fields[0];
200
382
  t_2 = a;
201
383
  break;
202
384
  }
385
+ case 16: {
386
+ matchResult = 14;
387
+ other_4 = a;
388
+ break;
389
+ }
203
390
  default:
204
- matchResult = 12;
391
+ matchResult = 15;
205
392
  }
206
393
  break;
207
394
  }
@@ -219,12 +406,17 @@ function unify(typeDefs, t1, t2, span) {
219
406
  }
220
407
  case 12: {
221
408
  matchResult = 11;
222
- name_2 = b.fields[0];
409
+ name_3 = b.fields[0];
223
410
  t_2 = a;
224
411
  break;
225
412
  }
413
+ case 16: {
414
+ matchResult = 14;
415
+ other_4 = a;
416
+ break;
417
+ }
226
418
  default:
227
- matchResult = 12;
419
+ matchResult = 15;
228
420
  }
229
421
  break;
230
422
  }
@@ -238,7 +430,7 @@ function unify(typeDefs, t1, t2, span) {
238
430
  }
239
431
  else {
240
432
  matchResult = 10;
241
- name_1 = a.fields[0];
433
+ name_2 = a.fields[0];
242
434
  t_1 = b;
243
435
  }
244
436
  break;
@@ -249,9 +441,15 @@ function unify(typeDefs, t1, t2, span) {
249
441
  v = b.fields[0];
250
442
  break;
251
443
  }
444
+ case 16: {
445
+ matchResult = 10;
446
+ name_2 = a.fields[0];
447
+ t_1 = b;
448
+ break;
449
+ }
252
450
  default: {
253
451
  matchResult = 10;
254
- name_1 = a.fields[0];
452
+ name_2 = a.fields[0];
255
453
  t_1 = b;
256
454
  }
257
455
  }
@@ -273,12 +471,17 @@ function unify(typeDefs, t1, t2, span) {
273
471
  }
274
472
  case 12: {
275
473
  matchResult = 11;
276
- name_2 = b.fields[0];
474
+ name_3 = b.fields[0];
277
475
  t_2 = a;
278
476
  break;
279
477
  }
478
+ case 16: {
479
+ matchResult = 14;
480
+ other_4 = a;
481
+ break;
482
+ }
280
483
  default:
281
- matchResult = 12;
484
+ matchResult = 15;
282
485
  }
283
486
  break;
284
487
  }
@@ -298,12 +501,17 @@ function unify(typeDefs, t1, t2, span) {
298
501
  }
299
502
  case 12: {
300
503
  matchResult = 11;
301
- name_2 = b.fields[0];
504
+ name_3 = b.fields[0];
302
505
  t_2 = a;
303
506
  break;
304
507
  }
508
+ case 16: {
509
+ matchResult = 14;
510
+ other_4 = a;
511
+ break;
512
+ }
305
513
  default:
306
- matchResult = 12;
514
+ matchResult = 15;
307
515
  }
308
516
  break;
309
517
  }
@@ -323,12 +531,17 @@ function unify(typeDefs, t1, t2, span) {
323
531
  }
324
532
  case 12: {
325
533
  matchResult = 11;
326
- name_2 = b.fields[0];
534
+ name_3 = b.fields[0];
327
535
  t_2 = a;
328
536
  break;
329
537
  }
538
+ case 16: {
539
+ matchResult = 14;
540
+ other_4 = a;
541
+ break;
542
+ }
330
543
  default:
331
- matchResult = 12;
544
+ matchResult = 15;
332
545
  }
333
546
  break;
334
547
  }
@@ -348,12 +561,17 @@ function unify(typeDefs, t1, t2, span) {
348
561
  }
349
562
  case 12: {
350
563
  matchResult = 11;
351
- name_2 = b.fields[0];
564
+ name_3 = b.fields[0];
352
565
  t_2 = a;
353
566
  break;
354
567
  }
568
+ case 16: {
569
+ matchResult = 14;
570
+ other_4 = a;
571
+ break;
572
+ }
355
573
  default:
356
- matchResult = 12;
574
+ matchResult = 15;
357
575
  }
358
576
  break;
359
577
  }
@@ -375,12 +593,17 @@ function unify(typeDefs, t1, t2, span) {
375
593
  }
376
594
  case 12: {
377
595
  matchResult = 11;
378
- name_2 = b.fields[0];
596
+ name_3 = b.fields[0];
379
597
  t_2 = a;
380
598
  break;
381
599
  }
600
+ case 16: {
601
+ matchResult = 14;
602
+ other_4 = a;
603
+ break;
604
+ }
382
605
  default:
383
- matchResult = 12;
606
+ matchResult = 15;
384
607
  }
385
608
  break;
386
609
  }
@@ -388,8 +611,8 @@ function unify(typeDefs, t1, t2, span) {
388
611
  switch (b.tag) {
389
612
  case 10: {
390
613
  matchResult = 7;
391
- x_7 = a.fields[0];
392
- y_7 = b.fields[0];
614
+ x_5 = a.fields[0];
615
+ y_5 = b.fields[0];
393
616
  break;
394
617
  }
395
618
  case 15: {
@@ -400,12 +623,17 @@ function unify(typeDefs, t1, t2, span) {
400
623
  }
401
624
  case 12: {
402
625
  matchResult = 11;
403
- name_2 = b.fields[0];
626
+ name_3 = b.fields[0];
404
627
  t_2 = a;
405
628
  break;
406
629
  }
630
+ case 16: {
631
+ matchResult = 14;
632
+ other_4 = a;
633
+ break;
634
+ }
407
635
  default:
408
- matchResult = 12;
636
+ matchResult = 15;
409
637
  }
410
638
  break;
411
639
  }
@@ -427,12 +655,17 @@ function unify(typeDefs, t1, t2, span) {
427
655
  }
428
656
  case 12: {
429
657
  matchResult = 11;
430
- name_2 = b.fields[0];
658
+ name_3 = b.fields[0];
431
659
  t_2 = a;
432
660
  break;
433
661
  }
662
+ case 16: {
663
+ matchResult = 14;
664
+ other_4 = a;
665
+ break;
666
+ }
434
667
  default:
435
- matchResult = 12;
668
+ matchResult = 15;
436
669
  }
437
670
  break;
438
671
  }
@@ -442,6 +675,45 @@ function unify(typeDefs, t1, t2, span) {
442
675
  v = a.fields[0];
443
676
  break;
444
677
  }
678
+ case 16: {
679
+ switch (b.tag) {
680
+ case 15: {
681
+ matchResult = 9;
682
+ t = a;
683
+ v = b.fields[0];
684
+ break;
685
+ }
686
+ case 12: {
687
+ matchResult = 11;
688
+ name_3 = b.fields[0];
689
+ t_2 = a;
690
+ break;
691
+ }
692
+ case 16: {
693
+ matchResult = 12;
694
+ v_1 = a.fields[0];
695
+ w = b.fields[0];
696
+ break;
697
+ }
698
+ case 1: {
699
+ matchResult = 13;
700
+ concrete = b;
701
+ v_2 = a.fields[0];
702
+ break;
703
+ }
704
+ case 2: {
705
+ matchResult = 13;
706
+ concrete = b;
707
+ v_2 = a.fields[0];
708
+ break;
709
+ }
710
+ default: {
711
+ matchResult = 14;
712
+ other_4 = b;
713
+ }
714
+ }
715
+ break;
716
+ }
445
717
  default:
446
718
  switch (b.tag) {
447
719
  case 15: {
@@ -452,12 +724,17 @@ function unify(typeDefs, t1, t2, span) {
452
724
  }
453
725
  case 12: {
454
726
  matchResult = 11;
455
- name_2 = b.fields[0];
727
+ name_3 = b.fields[0];
456
728
  t_2 = a;
457
729
  break;
458
730
  }
731
+ case 16: {
732
+ matchResult = 14;
733
+ other_4 = a;
734
+ break;
735
+ }
459
736
  default:
460
- matchResult = 12;
737
+ matchResult = 15;
461
738
  }
462
739
  }
463
740
  switch (matchResult) {
@@ -484,26 +761,16 @@ function unify(typeDefs, t1, t2, span) {
484
761
  return fold((sAcc, tupledArg) => compose(uni(seen$0027, applyType(sAcc, tupledArg[0]), applyType(sAcc, tupledArg[1])), sAcc), emptySubst, zip(xs, ys));
485
762
  }
486
763
  case 5: {
487
- const xKeys = ofSeq(FSharpMap__get_Keys(xf), {
488
- Compare: (x_5, y_5) => (comparePrimitives(x_5, y_5) | 0),
489
- });
490
- const yKeys = ofSeq(FSharpMap__get_Keys(yf), {
491
- Compare: (x_6, y_6) => (comparePrimitives(x_6, y_6) | 0),
492
- });
493
- let patternInput;
494
- if (isSubset(xKeys, yKeys)) {
495
- patternInput = [xf, yf];
496
- }
497
- else if (isSubset(yKeys, xKeys)) {
498
- patternInput = [yf, xf];
499
- }
500
- else {
764
+ const patternInput = (FSharpMap__get_Count(xf) <= FSharpMap__get_Count(yf)) ? [xf, yf] : [yf, xf];
765
+ const otherFields = patternInput[1];
766
+ const fieldsToCheck = patternInput[0];
767
+ if (exists_1((name, _arg) => !FSharpMap__ContainsKey(otherFields, name), fieldsToCheck)) {
501
768
  throw new TypeException(new TypeError$("Record field set mismatch", span));
502
769
  }
503
770
  return fold((sAcc_1, tupledArg_1) => {
504
- const yt = FSharpMap__get_Item(patternInput[1], tupledArg_1[0]);
771
+ const yt = FSharpMap__get_Item(otherFields, tupledArg_1[0]);
505
772
  return compose(uni(seen$0027, applyType(sAcc_1, tupledArg_1[1]), applyType(sAcc_1, yt)), sAcc_1);
506
- }, emptySubst, toList(patternInput[0]));
773
+ }, emptySubst, toList(fieldsToCheck));
507
774
  }
508
775
  case 6: {
509
776
  const s1_2 = uni(seen$0027, kx, ky);
@@ -511,8 +778,8 @@ function unify(typeDefs, t1, t2, span) {
511
778
  }
512
779
  case 7: {
513
780
  seen_mut = seen$0027;
514
- a_mut = x_7;
515
- b_mut = y_7;
781
+ a_mut = x_5;
782
+ b_mut = y_5;
516
783
  continue uni;
517
784
  }
518
785
  case 8: {
@@ -520,22 +787,27 @@ function unify(typeDefs, t1, t2, span) {
520
787
  return compose(uni(seen$0027, applyType(s1_3, b1), applyType(s1_3, b2)), s1_3);
521
788
  }
522
789
  case 9:
523
- if (equals(t, new Type(15, [v]))) {
790
+ if (equals(t, new Type(/* TVar */ 15, [v]))) {
524
791
  return emptySubst;
525
792
  }
793
+ else if (equals(t, new Type(/* TNumeric */ 16, [v]))) {
794
+ return ofList(singleton([v, t]), {
795
+ Compare: (x_6, y_6) => (comparePrimitives(x_6, y_6) | 0),
796
+ });
797
+ }
526
798
  else if (occurs(v, t)) {
527
799
  throw new TypeException(new TypeError$("Occurs check failed", span));
528
800
  }
529
801
  else {
530
802
  return ofList(singleton([v, t]), {
531
- Compare: (x_8, y_8) => (comparePrimitives(x_8, y_8) | 0),
803
+ Compare: (x_7, y_7) => (comparePrimitives(x_7, y_7) | 0),
532
804
  });
533
805
  }
534
806
  case 10: {
535
- const matchValue_1 = FSharpMap__TryFind(typeDefs, name_1);
807
+ const matchValue_1 = FSharpMap__TryFind(typeDefs, name_2);
536
808
  let matchResult_1, expanded_1;
537
809
  if (matchValue_1 != null) {
538
- if (!equals(matchValue_1, new Type(12, [name_1]))) {
810
+ if (!equals(matchValue_1, new Type(/* TNamed */ 12, [name_2]))) {
539
811
  matchResult_1 = 0;
540
812
  expanded_1 = matchValue_1;
541
813
  }
@@ -556,7 +828,7 @@ function unify(typeDefs, t1, t2, span) {
556
828
  default: {
557
829
  let matchResult_2, other_1;
558
830
  if (t_1.tag === 12) {
559
- if (t_1.fields[0] === name_1) {
831
+ if (t_1.fields[0] === name_2) {
560
832
  matchResult_2 = 0;
561
833
  other_1 = t_1.fields[0];
562
834
  }
@@ -577,10 +849,10 @@ function unify(typeDefs, t1, t2, span) {
577
849
  }
578
850
  }
579
851
  case 11: {
580
- const matchValue_2 = FSharpMap__TryFind(typeDefs, name_2);
852
+ const matchValue_2 = FSharpMap__TryFind(typeDefs, name_3);
581
853
  let matchResult_3, expanded_3;
582
854
  if (matchValue_2 != null) {
583
- if (!equals(matchValue_2, new Type(12, [name_2]))) {
855
+ if (!equals(matchValue_2, new Type(/* TNamed */ 12, [name_3]))) {
584
856
  matchResult_3 = 0;
585
857
  expanded_3 = matchValue_2;
586
858
  }
@@ -601,7 +873,7 @@ function unify(typeDefs, t1, t2, span) {
601
873
  default: {
602
874
  let matchResult_4, other_3;
603
875
  if (t_2.tag === 12) {
604
- if (t_2.fields[0] === name_2) {
876
+ if (t_2.fields[0] === name_3) {
605
877
  matchResult_4 = 0;
606
878
  other_3 = t_2.fields[0];
607
879
  }
@@ -621,15 +893,30 @@ function unify(typeDefs, t1, t2, span) {
621
893
  }
622
894
  }
623
895
  }
896
+ case 12:
897
+ if (v_1 === w) {
898
+ return emptySubst;
899
+ }
900
+ else {
901
+ return ofList(singleton([v_1, new Type(/* TNumeric */ 16, [w])]), {
902
+ Compare: (x_8, y_8) => (comparePrimitives(x_8, y_8) | 0),
903
+ });
904
+ }
905
+ case 13:
906
+ return ofList(singleton([v_2, concrete]), {
907
+ Compare: (x_9, y_9) => (comparePrimitives(x_9, y_9) | 0),
908
+ });
909
+ case 14:
910
+ throw new TypeException(new TypeError$((arg_4 = Types_typeToString(other_4), toText(printf("Expected numeric type, got %s"))(arg_4)), span));
624
911
  default:
625
- throw new TypeException(new TypeError$((arg_4 = Types_typeToString(a), (arg_5 = Types_typeToString(b), toText(printf("Type mismatch: %s vs %s"))(arg_4)(arg_5))), span));
912
+ throw new TypeException(new TypeError$((arg_5 = Types_typeToString(a), (arg_6 = Types_typeToString(b), toText(printf("Type mismatch: %s vs %s"))(arg_5)(arg_6))), span));
626
913
  }
627
914
  }
628
915
  break;
629
916
  }
630
917
  };
631
918
  return uni(empty_1({
632
- Compare: (x_9, y_9) => (compareArrays(x_9, y_9) | 0),
919
+ Compare: (x_10, y_10) => (compareArrays(x_10, y_10) | 0),
633
920
  }), t1, t2);
634
921
  }
635
922
 
@@ -641,20 +928,42 @@ function instantiate(_arg) {
641
928
  switch (t_1.tag) {
642
929
  case 15:
643
930
  return defaultArg(tryFind(t_1.fields[0], freshMap), t_1);
931
+ case 16: {
932
+ const matchValue = tryFind(t_1.fields[0], freshMap);
933
+ let matchResult, fresh;
934
+ if (matchValue != null) {
935
+ if (matchValue.tag === 15) {
936
+ matchResult = 0;
937
+ fresh = matchValue.fields[0];
938
+ }
939
+ else {
940
+ matchResult = 1;
941
+ }
942
+ }
943
+ else {
944
+ matchResult = 1;
945
+ }
946
+ switch (matchResult) {
947
+ case 0:
948
+ return new Type(/* TNumeric */ 16, [fresh]);
949
+ default:
950
+ return t_1;
951
+ }
952
+ }
644
953
  case 5:
645
- return new Type(5, [subst(t_1.fields[0])]);
954
+ return new Type(/* TList */ 5, [subst(t_1.fields[0])]);
646
955
  case 6:
647
- return new Type(6, [subst(t_1.fields[0])]);
956
+ return new Type(/* TTask */ 6, [subst(t_1.fields[0])]);
648
957
  case 7:
649
- return new Type(7, [map(subst, t_1.fields[0])]);
958
+ return new Type(/* TTuple */ 7, [map(subst, t_1.fields[0])]);
650
959
  case 8:
651
- return new Type(8, [map_1((_arg_1, t1) => subst(t1), t_1.fields[0])]);
960
+ return new Type(/* TRecord */ 8, [map_1((_arg_1, t1) => subst(t1), t_1.fields[0])]);
652
961
  case 9:
653
- return new Type(9, [subst(t_1.fields[0]), subst(t_1.fields[1])]);
962
+ return new Type(/* TMap */ 9, [subst(t_1.fields[0]), subst(t_1.fields[1])]);
654
963
  case 10:
655
- return new Type(10, [subst(t_1.fields[0])]);
964
+ return new Type(/* TOption */ 10, [subst(t_1.fields[0])]);
656
965
  case 11:
657
- return new Type(11, [subst(t_1.fields[0]), subst(t_1.fields[1])]);
966
+ return new Type(/* TFun */ 11, [subst(t_1.fields[0]), subst(t_1.fields[1])]);
658
967
  default:
659
968
  return t_1;
660
969
  }
@@ -728,21 +1037,22 @@ function InferenceTelemetry_$reflection() {
728
1037
  return record_type("FScript.Language.TypeInfer.InferenceTelemetry", [], InferenceTelemetry, () => [["ScopeStack", list_type(class_type("Microsoft.FSharp.Collections.FSharpSet`1", [string_type]))], ["LocalVariableTypes", array_type(LocalVariableTypeCapture_$reflection())]]);
729
1038
  }
730
1039
 
731
- let telemetry = undefined;
732
-
733
- function beginTelemetry() {
734
- telemetry = (new InferenceTelemetry(singleton(empty_1({
1040
+ function createTelemetry() {
1041
+ return new InferenceTelemetry(singleton(empty_1({
735
1042
  Compare: (x, y) => (comparePrimitives(x, y) | 0),
736
- })), []));
1043
+ })), []);
737
1044
  }
738
1045
 
739
- function endTelemetry() {
740
- const captured = (telemetry == null) ? empty_2() : toList_1(map_2((item) => (new LocalVariableTypeInfo(item.Name, item.Span, item.Type)), telemetry.LocalVariableTypes));
741
- telemetry = undefined;
742
- return captured;
1046
+ function capturedLocalVariableTypes(telemetry) {
1047
+ if (telemetry == null) {
1048
+ return empty_2();
1049
+ }
1050
+ else {
1051
+ return toList_1(map_2((item) => (new LocalVariableTypeInfo(item.Name, item.Span, item.Type)), telemetry.LocalVariableTypes));
1052
+ }
743
1053
  }
744
1054
 
745
- function withLocalBindings(names, work) {
1055
+ function withLocalBindings(telemetry, names, work) {
746
1056
  let matchValue;
747
1057
  if (telemetry != null) {
748
1058
  const t = telemetry;
@@ -753,7 +1063,7 @@ function withLocalBindings(names, work) {
753
1063
  else {
754
1064
  return add_1(name, acc);
755
1065
  }
756
- }, (matchValue = t.ScopeStack, isEmpty(matchValue) ? empty_1({
1066
+ }, (matchValue = t.ScopeStack, isEmpty_1(matchValue) ? empty_1({
757
1067
  Compare: (x, y) => (comparePrimitives(x, y) | 0),
758
1068
  }) : head_1(matchValue)), names);
759
1069
  t.ScopeStack = cons(pushed, t.ScopeStack);
@@ -762,7 +1072,7 @@ function withLocalBindings(names, work) {
762
1072
  }
763
1073
  finally {
764
1074
  const matchValue_1 = t.ScopeStack;
765
- if (isEmpty(matchValue_1)) {
1075
+ if (isEmpty_1(matchValue_1)) {
766
1076
  }
767
1077
  else {
768
1078
  t.ScopeStack = tail_2(matchValue_1);
@@ -774,11 +1084,11 @@ function withLocalBindings(names, work) {
774
1084
  }
775
1085
  }
776
1086
 
777
- function recordLocalVariableUse(name, span, varType) {
1087
+ function recordLocalVariableUse(telemetry, name, span, varType) {
778
1088
  let matchValue;
779
1089
  if (telemetry != null) {
780
1090
  const t = telemetry;
781
- if (contains(name, (matchValue = t.ScopeStack, isEmpty(matchValue) ? empty_1({
1091
+ if (contains(name, (matchValue = t.ScopeStack, isEmpty_1(matchValue) ? empty_1({
782
1092
  Compare: (x, y) => (comparePrimitives(x, y) | 0),
783
1093
  }) : head_1(matchValue)))) {
784
1094
  void (t.LocalVariableTypes.push(new LocalVariableTypeCapture(name, span, varType)));
@@ -786,7 +1096,7 @@ function recordLocalVariableUse(name, span, varType) {
786
1096
  }
787
1097
  }
788
1098
 
789
- function recordLocalVariableDeclaration(name, span, varType) {
1099
+ function recordLocalVariableDeclaration(telemetry, name, span, varType) {
790
1100
  if (isNullOrWhiteSpace(name) ? true : (name === "_")) {
791
1101
  }
792
1102
  else if (telemetry != null) {
@@ -795,7 +1105,7 @@ function recordLocalVariableDeclaration(name, span, varType) {
795
1105
  }
796
1106
  }
797
1107
 
798
- function applySubstToCapturedLocals(startIndex, subst) {
1108
+ function applySubstToCapturedLocals(telemetry, startIndex, subst) {
799
1109
  if (telemetry != null) {
800
1110
  const t = telemetry;
801
1111
  for (let i = startIndex; i <= (t.LocalVariableTypes.length - 1); i++) {
@@ -805,7 +1115,7 @@ function applySubstToCapturedLocals(startIndex, subst) {
805
1115
  }
806
1116
  }
807
1117
 
808
- function currentTelemetryCaptureCount() {
1118
+ function currentTelemetryCaptureCount(telemetry) {
809
1119
  if (telemetry == null) {
810
1120
  return 0;
811
1121
  }
@@ -834,15 +1144,17 @@ function asTyped(expr, t) {
834
1144
  function builtinType(name) {
835
1145
  switch (name) {
836
1146
  case "unit":
837
- return new Type(0, []);
1147
+ return Type.TUnit;
838
1148
  case "int":
839
- return new Type(1, []);
1149
+ return Type.TInt;
840
1150
  case "float":
841
- return new Type(2, []);
1151
+ return Type.TFloat;
1152
+ case "numeric":
1153
+ return Types_freshNumeric();
842
1154
  case "bool":
843
- return new Type(3, []);
1155
+ return Type.TBool;
844
1156
  case "string":
845
- return new Type(4, []);
1157
+ return Type.TString;
846
1158
  default:
847
1159
  return undefined;
848
1160
  }
@@ -871,14 +1183,14 @@ function resolveNamedRecordByShape(typeDefs, shape, span) {
871
1183
  return undefined;
872
1184
  }
873
1185
  }, toList(typeDefs));
874
- if (isEmpty(matches)) {
875
- throw new TypeException(new TypeError$(concat("No declared record type matches shape ", Types_typeToString(new Type(8, [shape]))), span));
1186
+ if (isEmpty_1(matches)) {
1187
+ throw new TypeException(new TypeError$(concat("No declared record type matches shape ", Types_typeToString(new Type(/* TRecord */ 8, [shape]))), span));
876
1188
  }
877
- else if (isEmpty(tail_2(matches))) {
878
- return new Type(12, [head_1(matches)]);
1189
+ else if (isEmpty_1(tail_2(matches))) {
1190
+ return new Type(/* TNamed */ 12, [head_1(matches)]);
879
1191
  }
880
1192
  else {
881
- throw new TypeException(new TypeError$(concat("Ambiguous declared record type for shape ", Types_typeToString(new Type(8, [shape])), ": ", join(", ", matches)), span));
1193
+ throw new TypeException(new TypeError$(concat("Ambiguous declared record type for shape ", Types_typeToString(new Type(/* TRecord */ 8, [shape])), ": ", join(", ", matches)), span));
882
1194
  }
883
1195
  }
884
1196
 
@@ -907,10 +1219,10 @@ function resolveNamedRecordByFieldSet(typeDefs, fields, span) {
907
1219
  return undefined;
908
1220
  }
909
1221
  }, toList(typeDefs));
910
- if (isEmpty(matches)) {
1222
+ if (isEmpty_1(matches)) {
911
1223
  throw new TypeException(new TypeError$(concat("No declared record type matches fields ", concat("{ ", join("; ", toList_2(fields)), " }")), span));
912
1224
  }
913
- else if (isEmpty(tail_2(matches))) {
1225
+ else if (isEmpty_1(tail_2(matches))) {
914
1226
  return head_1(matches);
915
1227
  }
916
1228
  else {
@@ -937,10 +1249,10 @@ function resolveReferencedTypeName(knownNames, name, span) {
937
1249
  Equals: (x_1, y_1) => (x_1 === y_1),
938
1250
  GetHashCode: (x_1) => (stringHash(x_1) | 0),
939
1251
  }));
940
- if (isEmpty(matches)) {
1252
+ if (isEmpty_1(matches)) {
941
1253
  return name;
942
1254
  }
943
- else if (isEmpty(tail_2(matches))) {
1255
+ else if (isEmpty_1(tail_2(matches))) {
944
1256
  return head_1(matches);
945
1257
  }
946
1258
  else {
@@ -955,19 +1267,19 @@ function resolveReferencedTypeName(knownNames, name, span) {
955
1267
  function annotationTypeFromRef(typeDefs, span, tref) {
956
1268
  switch (tref.tag) {
957
1269
  case 1:
958
- return new Type(7, [map((tref_1) => annotationTypeFromRef(typeDefs, span, tref_1), tref.fields[0])]);
1270
+ return new Type(/* TTuple */ 7, [map((tref_1) => annotationTypeFromRef(typeDefs, span, tref_1), tref.fields[0])]);
959
1271
  case 2:
960
- return new Type(11, [annotationTypeFromRef(typeDefs, span, tref.fields[0]), annotationTypeFromRef(typeDefs, span, tref.fields[1])]);
1272
+ return new Type(/* TFun */ 11, [annotationTypeFromRef(typeDefs, span, tref.fields[0]), annotationTypeFromRef(typeDefs, span, tref.fields[1])]);
961
1273
  case 3:
962
1274
  switch (tref.fields[1]) {
963
1275
  case "list":
964
- return new Type(5, [annotationTypeFromRef(typeDefs, span, tref.fields[0])]);
1276
+ return new Type(/* TList */ 5, [annotationTypeFromRef(typeDefs, span, tref.fields[0])]);
965
1277
  case "task":
966
- return new Type(6, [annotationTypeFromRef(typeDefs, span, tref.fields[0])]);
1278
+ return new Type(/* TTask */ 6, [annotationTypeFromRef(typeDefs, span, tref.fields[0])]);
967
1279
  case "option":
968
- return new Type(10, [annotationTypeFromRef(typeDefs, span, tref.fields[0])]);
1280
+ return new Type(/* TOption */ 10, [annotationTypeFromRef(typeDefs, span, tref.fields[0])]);
969
1281
  case "map":
970
- return new Type(9, [new Type(4, []), annotationTypeFromRef(typeDefs, span, tref.fields[0])]);
1282
+ return new Type(/* TMap */ 9, [Type.TString, annotationTypeFromRef(typeDefs, span, tref.fields[0])]);
971
1283
  default:
972
1284
  throw new TypeException(new TypeError$(concat("Unknown type suffix \'", tref.fields[1], "\'"), span));
973
1285
  }
@@ -976,23 +1288,25 @@ function annotationTypeFromRef(typeDefs, span, tref) {
976
1288
  Compare: (x, y) => (comparePrimitives(x, y) | 0),
977
1289
  }), span);
978
1290
  case 5:
979
- return new Type(8, [ofList(map((tupledArg_1) => [tupledArg_1[0], annotationTypeFromRef(typeDefs, span, tupledArg_1[1])], tref.fields[0]), {
1291
+ return new Type(/* TRecord */ 8, [ofList(map((tupledArg_1) => [tupledArg_1[0], annotationTypeFromRef(typeDefs, span, tupledArg_1[1])], tref.fields[0]), {
980
1292
  Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
981
1293
  })]);
982
1294
  default:
983
1295
  switch (tref.fields[0]) {
984
1296
  case "unit":
985
- return new Type(0, []);
1297
+ return Type.TUnit;
986
1298
  case "int":
987
- return new Type(1, []);
1299
+ return Type.TInt;
988
1300
  case "float":
989
- return new Type(2, []);
1301
+ return Type.TFloat;
1302
+ case "numeric":
1303
+ return Types_freshNumeric();
990
1304
  case "bool":
991
- return new Type(3, []);
1305
+ return Type.TBool;
992
1306
  case "string":
993
- return new Type(4, []);
1307
+ return Type.TString;
994
1308
  default:
995
- return new Type(12, [resolveReferencedTypeName(FSharpMap__get_Keys(typeDefs), tref.fields[0], span)]);
1309
+ return new Type(/* TNamed */ 12, [resolveReferencedTypeName(FSharpMap__get_Keys(typeDefs), tref.fields[0], span)]);
996
1310
  }
997
1311
  }
998
1312
  }
@@ -1015,31 +1329,31 @@ function functionReturnType(t_mut) {
1015
1329
  function typeFromRef(decls, stack, tref) {
1016
1330
  switch (tref.tag) {
1017
1331
  case 1:
1018
- return new Type(7, [map((tref_1) => typeFromRef(decls, stack, tref_1), tref.fields[0])]);
1332
+ return new Type(/* TTuple */ 7, [map((tref_1) => typeFromRef(decls, stack, tref_1), tref.fields[0])]);
1019
1333
  case 2:
1020
- return new Type(11, [typeFromRef(decls, stack, tref.fields[0]), typeFromRef(decls, stack, tref.fields[1])]);
1334
+ return new Type(/* TFun */ 11, [typeFromRef(decls, stack, tref.fields[0]), typeFromRef(decls, stack, tref.fields[1])]);
1021
1335
  case 3: {
1022
1336
  const suffix = tref.fields[1];
1023
1337
  const resolved = typeFromRef(decls, stack, tref.fields[0]);
1024
1338
  switch (suffix) {
1025
1339
  case "list":
1026
- return new Type(5, [resolved]);
1340
+ return new Type(/* TList */ 5, [resolved]);
1027
1341
  case "task":
1028
- return new Type(6, [resolved]);
1342
+ return new Type(/* TTask */ 6, [resolved]);
1029
1343
  case "option":
1030
- return new Type(10, [resolved]);
1344
+ return new Type(/* TOption */ 10, [resolved]);
1031
1345
  case "map":
1032
- return new Type(9, [new Type(4, []), resolved]);
1346
+ return new Type(/* TMap */ 9, [Type.TString, resolved]);
1033
1347
  default:
1034
1348
  throw new TypeException(new TypeError$(concat("Unknown type suffix \'", suffix, "\'"), unknownSpan));
1035
1349
  }
1036
1350
  }
1037
1351
  case 4:
1038
- return new Type(8, [ofList(map((tupledArg_1) => [tupledArg_1[0], typeFromRef(decls, stack, tupledArg_1[1])], tref.fields[0]), {
1352
+ return new Type(/* TRecord */ 8, [ofList(map((tupledArg_1) => [tupledArg_1[0], typeFromRef(decls, stack, tupledArg_1[1])], tref.fields[0]), {
1039
1353
  Compare: (x_1, y_2) => (comparePrimitives(x_1, y_2) | 0),
1040
1354
  })]);
1041
1355
  case 5:
1042
- return new Type(8, [ofList(map((tupledArg_2) => [tupledArg_2[0], typeFromRef(decls, stack, tupledArg_2[1])], tref.fields[0]), {
1356
+ return new Type(/* TRecord */ 8, [ofList(map((tupledArg_2) => [tupledArg_2[0], typeFromRef(decls, stack, tupledArg_2[1])], tref.fields[0]), {
1043
1357
  Compare: (x_2, y_3) => (comparePrimitives(x_2, y_3) | 0),
1044
1358
  })]);
1045
1359
  default: {
@@ -1049,24 +1363,24 @@ function typeFromRef(decls, stack, tref) {
1049
1363
  const resolvedName = resolveReferencedTypeName(FSharpMap__get_Keys(decls), name, unknownSpan);
1050
1364
  const matchValue_1 = FSharpMap__TryFind(decls, resolvedName);
1051
1365
  if (matchValue_1 == null) {
1052
- return new Type(12, [resolvedName]);
1366
+ return new Type(/* TNamed */ 12, [resolvedName]);
1053
1367
  }
1054
1368
  else {
1055
1369
  const def = matchValue_1;
1056
1370
  const matchValue_2 = tryFindIndex((y) => (resolvedName === y), stack);
1057
1371
  if (matchValue_2 == null) {
1058
- if (!isEmpty(def.Cases)) {
1059
- return new Type(12, [resolvedName]);
1372
+ if (!isEmpty_1(def.Cases)) {
1373
+ return new Type(/* TNamed */ 12, [resolvedName]);
1060
1374
  }
1061
1375
  else {
1062
- return new Type(8, [ofList(map((tupledArg) => [tupledArg[0], typeFromRef(decls, cons(resolvedName, stack), tupledArg[1])], def.Fields), {
1376
+ return new Type(/* TRecord */ 8, [ofList(map((tupledArg) => [tupledArg[0], typeFromRef(decls, cons(resolvedName, stack), tupledArg[1])], def.Fields), {
1063
1377
  Compare: (x, y_1) => (comparePrimitives(x, y_1) | 0),
1064
1378
  })]);
1065
1379
  }
1066
1380
  }
1067
1381
  else if (matchValue_2 === 0) {
1068
1382
  if (def.IsRecursive) {
1069
- return new Type(12, [resolvedName]);
1383
+ return new Type(/* TNamed */ 12, [resolvedName]);
1070
1384
  }
1071
1385
  else {
1072
1386
  throw new TypeException(new TypeError$(concat("Recursive type \'", resolvedName, "\' requires \'type rec\'"), unknownSpan));
@@ -1084,20 +1398,20 @@ function typeFromRef(decls, stack, tref) {
1084
1398
  }
1085
1399
  }
1086
1400
 
1087
- function inferPattern(typeDefs, constructors, pat) {
1401
+ function inferPattern(telemetry, typeDefs, constructors, pat) {
1088
1402
  let table_5;
1089
1403
  switch (pat.tag) {
1090
1404
  case 1: {
1091
1405
  const name = pat.fields[0];
1092
1406
  const tv = Types_freshVar();
1093
- recordLocalVariableDeclaration(name, Ast_spanOfPattern(pat), tv);
1407
+ recordLocalVariableDeclaration(telemetry, name, Ast_spanOfPattern(pat), tv);
1094
1408
  return [ofList(singleton([name, tv]), {
1095
1409
  Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
1096
1410
  }), tv];
1097
1411
  }
1098
1412
  case 2: {
1099
1413
  const lit = pat.fields[0];
1100
- const t = (lit.tag === 1) ? (new Type(2, [])) : ((lit.tag === 2) ? (new Type(3, [])) : ((lit.tag === 3) ? (new Type(4, [])) : (new Type(1, []))));
1414
+ const t = (lit.tag === 1) ? Type.TFloat : ((lit.tag === 2) ? Type.TBool : ((lit.tag === 3) ? Type.TString : Type.TInt));
1101
1415
  return [empty({
1102
1416
  Compare: (x_2, y_2) => (comparePrimitives(x_2, y_2) | 0),
1103
1417
  }), t];
@@ -1106,43 +1420,43 @@ function inferPattern(typeDefs, constructors, pat) {
1106
1420
  const tv_1 = Types_freshVar();
1107
1421
  return [empty({
1108
1422
  Compare: (x_3, y_3) => (comparePrimitives(x_3, y_3) | 0),
1109
- }), new Type(5, [tv_1])];
1423
+ }), new Type(/* TList */ 5, [tv_1])];
1110
1424
  }
1111
1425
  case 4: {
1112
- const startIndex = currentTelemetryCaptureCount() | 0;
1113
- const patternInput = inferPattern(typeDefs, constructors, pat.fields[0]);
1426
+ const startIndex = currentTelemetryCaptureCount(telemetry) | 0;
1427
+ const patternInput = inferPattern(telemetry, typeDefs, constructors, pat.fields[0]);
1114
1428
  const t1 = patternInput[1];
1115
- const patternInput_1 = inferPattern(typeDefs, constructors, pat.fields[1]);
1429
+ const patternInput_1 = inferPattern(telemetry, typeDefs, constructors, pat.fields[1]);
1116
1430
  const s = unify(empty({
1117
1431
  Compare: (x_4, y_4) => (comparePrimitives(x_4, y_4) | 0),
1118
- }), patternInput_1[1], new Type(5, [t1]), pat.fields[2]);
1119
- applySubstToCapturedLocals(startIndex, s);
1120
- return [map_1((_arg, ty) => applyType(s, ty), fold_1((acc, k, v) => add(k, v, acc), patternInput[0], patternInput_1[0])), applyType(s, new Type(5, [t1]))];
1432
+ }), patternInput_1[1], new Type(/* TList */ 5, [t1]), pat.fields[2]);
1433
+ applySubstToCapturedLocals(telemetry, startIndex, s);
1434
+ return [map_1((_arg, ty) => applyType(s, ty), fold_1((acc, k, v) => add(k, v, acc), patternInput[0], patternInput_1[0])), applyType(s, new Type(/* TList */ 5, [t1]))];
1121
1435
  }
1122
1436
  case 5: {
1123
1437
  const patternInput_3 = fold((tupledArg, p) => {
1124
- const patternInput_2 = inferPattern(typeDefs, constructors, p);
1438
+ const patternInput_2 = inferPattern(telemetry, typeDefs, constructors, p);
1125
1439
  return [fold_1((acc_1, k_1, v_1) => add(k_1, v_1, acc_1), tupledArg[0], patternInput_2[0]), cons(patternInput_2[1], tupledArg[1])];
1126
1440
  }, [empty({
1127
1441
  Compare: (x_5, y_5) => (comparePrimitives(x_5, y_5) | 0),
1128
1442
  }), empty_2()], pat.fields[0]);
1129
- return [patternInput_3[0], new Type(7, [reverse(patternInput_3[1])])];
1443
+ return [patternInput_3[0], new Type(/* TTuple */ 7, [reverse(patternInput_3[1])])];
1130
1444
  }
1131
1445
  case 6: {
1132
1446
  const patternInput_5 = fold((tupledArg_1, tupledArg_2) => {
1133
- const patternInput_4 = inferPattern(typeDefs, constructors, tupledArg_2[1]);
1447
+ const patternInput_4 = inferPattern(telemetry, typeDefs, constructors, tupledArg_2[1]);
1134
1448
  return [fold_1((acc_2, k_2, v_2) => add(k_2, v_2, acc_2), tupledArg_1[0], patternInput_4[0]), add(tupledArg_2[0], patternInput_4[1], tupledArg_1[1])];
1135
1449
  }, [empty({
1136
1450
  Compare: (x_6, y_6) => (comparePrimitives(x_6, y_6) | 0),
1137
1451
  }), empty({
1138
1452
  Compare: (x_7, y_7) => (comparePrimitives(x_7, y_7) | 0),
1139
1453
  })], pat.fields[0]);
1140
- return [patternInput_5[0], new Type(8, [patternInput_5[1]])];
1454
+ return [patternInput_5[0], new Type(/* TRecord */ 8, [patternInput_5[1]])];
1141
1455
  }
1142
1456
  case 7: {
1143
1457
  const tailPattern = pat.fields[1];
1144
1458
  const span_1 = pat.fields[2];
1145
- const startIndex_1 = currentTelemetryCaptureCount() | 0;
1459
+ const startIndex_1 = currentTelemetryCaptureCount(telemetry) | 0;
1146
1460
  const ensureSupportedMapKeyType = (t_1) => {
1147
1461
  switch (t_1.tag) {
1148
1462
  case 4:
@@ -1163,8 +1477,8 @@ function inferPattern(typeDefs, constructors, pat) {
1163
1477
  try {
1164
1478
  while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
1165
1479
  const forLoopVar = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
1166
- const patternInput_6 = inferPattern(typeDefs, constructors, forLoopVar[0]);
1167
- const patternInput_7 = inferPattern(typeDefs, constructors, forLoopVar[1]);
1480
+ const patternInput_6 = inferPattern(telemetry, typeDefs, constructors, forLoopVar[0]);
1481
+ const patternInput_7 = inferPattern(telemetry, typeDefs, constructors, forLoopVar[1]);
1168
1482
  const sKey = unify(typeDefs, applyType(sAcc, patternInput_6[1]), applyType(sAcc, mapKeyType), span_1);
1169
1483
  sAcc = compose(sKey, sAcc);
1170
1484
  ensureSupportedMapKeyType(applyType(sAcc, mapKeyType));
@@ -1180,25 +1494,25 @@ function inferPattern(typeDefs, constructors, pat) {
1180
1494
  if (tailPattern == null) {
1181
1495
  }
1182
1496
  else {
1183
- const patternInput_8 = inferPattern(typeDefs, constructors, tailPattern);
1184
- const expectedTailType = new Type(9, [applyType(sAcc, mapKeyType), applyType(sAcc, valueType)]);
1497
+ const patternInput_8 = inferPattern(telemetry, typeDefs, constructors, tailPattern);
1498
+ const expectedTailType = new Type(/* TMap */ 9, [applyType(sAcc, mapKeyType), applyType(sAcc, valueType)]);
1185
1499
  const sTail = unify(typeDefs, applyType(sAcc, patternInput_8[1]), expectedTailType, span_1);
1186
1500
  sAcc = compose(sTail, sAcc);
1187
1501
  envAcc_2 = ((table_5 = map_1((_arg_2, t_3) => applyType(sAcc, t_3), patternInput_8[0]), fold_1((acc_5, k_5, v_5) => add(k_5, v_5, acc_5), envAcc_2, table_5)));
1188
1502
  }
1189
1503
  ensureSupportedMapKeyType(applyType(sAcc, mapKeyType));
1190
- applySubstToCapturedLocals(startIndex_1, sAcc);
1191
- return [map_1((_arg_3, t_4) => applyType(sAcc, t_4), envAcc_2), new Type(9, [applyType(sAcc, mapKeyType), applyType(sAcc, valueType)])];
1504
+ applySubstToCapturedLocals(telemetry, startIndex_1, sAcc);
1505
+ return [map_1((_arg_3, t_4) => applyType(sAcc, t_4), envAcc_2), new Type(/* TMap */ 9, [applyType(sAcc, mapKeyType), applyType(sAcc, valueType)])];
1192
1506
  }
1193
1507
  case 8: {
1194
- const patternInput_9 = inferPattern(typeDefs, constructors, pat.fields[0]);
1195
- return [patternInput_9[0], new Type(10, [patternInput_9[1]])];
1508
+ const patternInput_9 = inferPattern(telemetry, typeDefs, constructors, pat.fields[0]);
1509
+ return [patternInput_9[0], new Type(/* TOption */ 10, [patternInput_9[1]])];
1196
1510
  }
1197
1511
  case 9: {
1198
1512
  const tv_2 = Types_freshVar();
1199
1513
  return [empty({
1200
1514
  Compare: (x_9, y_9) => (comparePrimitives(x_9, y_9) | 0),
1201
- }), new Type(10, [tv_2])];
1515
+ }), new Type(/* TOption */ 10, [tv_2])];
1202
1516
  }
1203
1517
  case 10: {
1204
1518
  const span_2 = pat.fields[3];
@@ -1209,7 +1523,7 @@ function inferPattern(typeDefs, constructors, pat) {
1209
1523
  const matchValue = FSharpMap__TryFind(constructors, constructorName);
1210
1524
  if (matchValue != null) {
1211
1525
  const sigInfo = matchValue;
1212
- const unionType = new Type(12, [sigInfo.UnionName]);
1526
+ const unionType = new Type(/* TNamed */ 12, [sigInfo.UnionName]);
1213
1527
  const matchValue_1 = sigInfo.Payload;
1214
1528
  if (matchValue_1 != null) {
1215
1529
  if (payload == null) {
@@ -1218,10 +1532,10 @@ function inferPattern(typeDefs, constructors, pat) {
1218
1532
  else {
1219
1533
  const expectedPayload = matchValue_1;
1220
1534
  const payloadPattern = payload;
1221
- const startIndex_2 = currentTelemetryCaptureCount() | 0;
1222
- const patternInput_10 = inferPattern(typeDefs, constructors, payloadPattern);
1535
+ const startIndex_2 = currentTelemetryCaptureCount(telemetry) | 0;
1536
+ const patternInput_10 = inferPattern(telemetry, typeDefs, constructors, payloadPattern);
1223
1537
  const s_1 = unify(typeDefs, patternInput_10[1], expectedPayload, span_2);
1224
- applySubstToCapturedLocals(startIndex_2, s_1);
1538
+ applySubstToCapturedLocals(telemetry, startIndex_2, s_1);
1225
1539
  return [map_1((_arg_4, t_6) => applyType(s_1, t_6), patternInput_10[0]), unionType];
1226
1540
  }
1227
1541
  }
@@ -1249,15 +1563,17 @@ function inferPattern(typeDefs, constructors, pat) {
1249
1563
  }
1250
1564
  }
1251
1565
 
1252
- function numericResult(t, span) {
1566
+ function constrainNumeric(typeDefs, t, span) {
1253
1567
  switch (t.tag) {
1254
1568
  case 1:
1255
1569
  case 2:
1256
- return t;
1257
- case 15:
1258
- return new Type(1, []);
1259
- default:
1260
- throw new TypeException(new TypeError$("Expected numeric type", span));
1570
+ case 16:
1571
+ return [emptySubst, t];
1572
+ default: {
1573
+ const numeric = Types_freshNumeric();
1574
+ const subst = unify(typeDefs, t, numeric, span);
1575
+ return [subst, applyType(subst, numeric)];
1576
+ }
1261
1577
  }
1262
1578
  }
1263
1579
 
@@ -1319,12 +1635,12 @@ function validateMapKeyTypes(span, t) {
1319
1635
  loop(t);
1320
1636
  }
1321
1637
 
1322
- function inferExpr(typeDefs, constructors, env, expr) {
1638
+ function inferExpr(telemetry, typeDefs, constructors, env, expr) {
1323
1639
  let expectedReturn, expectedReturn_1;
1324
1640
  switch (expr.tag) {
1325
1641
  case 1: {
1326
1642
  const lit = expr.fields[0];
1327
- const t = (lit.tag === 1) ? (new Type(2, [])) : ((lit.tag === 2) ? (new Type(3, [])) : ((lit.tag === 3) ? (new Type(4, [])) : (new Type(1, []))));
1643
+ const t = (lit.tag === 1) ? Type.TFloat : ((lit.tag === 2) ? Type.TBool : ((lit.tag === 3) ? Type.TString : Type.TInt));
1328
1644
  return [emptySubst, t, asTyped(expr, t)];
1329
1645
  }
1330
1646
  case 2: {
@@ -1336,19 +1652,19 @@ function inferExpr(typeDefs, constructors, env, expr) {
1336
1652
  }
1337
1653
  else {
1338
1654
  const t_1 = instantiate(matchValue);
1339
- recordLocalVariableUse(name, span, t_1);
1655
+ recordLocalVariableUse(telemetry, name, span, t_1);
1340
1656
  return [emptySubst, t_1, asTyped(expr, t_1)];
1341
1657
  }
1342
1658
  }
1343
1659
  case 3: {
1344
- const patternInput = inferExpr(typeDefs, constructors, env, expr.fields[0]);
1660
+ const patternInput = inferExpr(telemetry, typeDefs, constructors, env, expr.fields[0]);
1345
1661
  const t_2 = patternInput[1];
1346
1662
  return [patternInput[0], t_2, asTyped(expr, t_2)];
1347
1663
  }
1348
1664
  case 28: {
1349
1665
  const name_1 = expr.fields[0];
1350
1666
  if (FSharpMap__ContainsKey(typeDefs, name_1)) {
1351
- return [emptySubst, new Type(14, []), asTyped(expr, new Type(14, []))];
1667
+ return [emptySubst, Type.TTypeToken, asTyped(expr, Type.TTypeToken)];
1352
1668
  }
1353
1669
  else {
1354
1670
  throw new TypeException(new TypeError$(toText(printf("Unknown type \'%s\'"))(name_1), expr.fields[1]));
@@ -1357,7 +1673,7 @@ function inferExpr(typeDefs, constructors, env, expr) {
1357
1673
  case 29: {
1358
1674
  const name_2 = expr.fields[0];
1359
1675
  if (FSharpMap__ContainsKey(env, name_2)) {
1360
- return [emptySubst, new Type(4, []), asTyped(expr, new Type(4, []))];
1676
+ return [emptySubst, Type.TString, asTyped(expr, Type.TString)];
1361
1677
  }
1362
1678
  else {
1363
1679
  throw new TypeException(new TypeError$(toText(printf("Unbound variable \'%s\'"))(name_2), expr.fields[1]));
@@ -1370,7 +1686,7 @@ function inferExpr(typeDefs, constructors, env, expr) {
1370
1686
  while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
1371
1687
  const part = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
1372
1688
  if (part.tag === 1) {
1373
- const patternInput_1 = inferExpr(typeDefs, constructors, applyEnv(sAcc, env), part.fields[0]);
1689
+ const patternInput_1 = inferExpr(telemetry, typeDefs, constructors, applyEnv(sAcc, env), part.fields[0]);
1374
1690
  sAcc = compose(patternInput_1[0], sAcc);
1375
1691
  }
1376
1692
  }
@@ -1378,38 +1694,38 @@ function inferExpr(typeDefs, constructors, env, expr) {
1378
1694
  finally {
1379
1695
  disposeSafe(enumerator);
1380
1696
  }
1381
- return [sAcc, new Type(4, []), asTyped(expr, new Type(4, []))];
1697
+ return [sAcc, Type.TString, asTyped(expr, Type.TString)];
1382
1698
  }
1383
1699
  case 4: {
1384
1700
  const param = expr.fields[0];
1385
1701
  let tv;
1386
1702
  const matchValue_1 = param.Annotation;
1387
1703
  tv = ((matchValue_1 == null) ? Types_freshVar() : annotationTypeFromRef(typeDefs, param.Span, matchValue_1));
1388
- recordLocalVariableDeclaration(param.Name, param.Span, tv);
1704
+ recordLocalVariableDeclaration(telemetry, param.Name, param.Span, tv);
1389
1705
  const env$0027 = add(param.Name, new Scheme(empty_2(), tv), env);
1390
- const patternInput_2 = withLocalBindings(singleton(param.Name), () => inferExpr(typeDefs, constructors, env$0027, expr.fields[1]));
1706
+ const patternInput_2 = withLocalBindings(telemetry, singleton(param.Name), () => inferExpr(telemetry, typeDefs, constructors, env$0027, expr.fields[1]));
1391
1707
  const s1_1 = patternInput_2[0];
1392
- const tFun = new Type(11, [applyType(s1_1, tv), patternInput_2[1]]);
1708
+ const tFun = new Type(/* TFun */ 11, [applyType(s1_1, tv), patternInput_2[1]]);
1393
1709
  return [s1_1, tFun, asTyped(expr, tFun)];
1394
1710
  }
1395
1711
  case 5: {
1396
- const patternInput_3 = inferExpr(typeDefs, constructors, env, expr.fields[0]);
1712
+ const patternInput_3 = inferExpr(telemetry, typeDefs, constructors, env, expr.fields[0]);
1397
1713
  const s1_2 = patternInput_3[0];
1398
- const patternInput_4 = inferExpr(typeDefs, constructors, applyEnv(s1_2, env), expr.fields[1]);
1714
+ const patternInput_4 = inferExpr(telemetry, typeDefs, constructors, applyEnv(s1_2, env), expr.fields[1]);
1399
1715
  const s2 = patternInput_4[0];
1400
1716
  const tv_1 = Types_freshVar();
1401
- const s_1 = compose(unify(typeDefs, applyType(s2, patternInput_3[1]), new Type(11, [patternInput_4[1], tv_1]), expr.fields[2]), compose(s2, s1_2));
1717
+ const s_1 = compose(unify(typeDefs, applyType(s2, patternInput_3[1]), new Type(/* TFun */ 11, [patternInput_4[1], tv_1]), expr.fields[2]), compose(s2, s1_2));
1402
1718
  const tRes = applyType(s_1, tv_1);
1403
1719
  return [s_1, tRes, asTyped(expr, tRes)];
1404
1720
  }
1405
1721
  case 6: {
1406
1722
  const span_5 = expr.fields[3];
1407
- const patternInput_5 = inferExpr(typeDefs, constructors, env, expr.fields[0]);
1723
+ const patternInput_5 = inferExpr(telemetry, typeDefs, constructors, env, expr.fields[0]);
1408
1724
  const s1_3 = patternInput_5[0];
1409
- const sBool = unify(typeDefs, patternInput_5[1], new Type(3, []), span_5);
1410
- const patternInput_6 = inferExpr(typeDefs, constructors, applyEnv(compose(sBool, s1_3), env), expr.fields[1]);
1725
+ const sBool = unify(typeDefs, patternInput_5[1], Type.TBool, span_5);
1726
+ const patternInput_6 = inferExpr(telemetry, typeDefs, constructors, applyEnv(compose(sBool, s1_3), env), expr.fields[1]);
1411
1727
  const s2_1 = patternInput_6[0];
1412
- const patternInput_7 = inferExpr(typeDefs, constructors, applyEnv(compose(s2_1, compose(sBool, s1_3)), env), expr.fields[2]);
1728
+ const patternInput_7 = inferExpr(telemetry, typeDefs, constructors, applyEnv(compose(s2_1, compose(sBool, s1_3)), env), expr.fields[2]);
1413
1729
  const tElse = patternInput_7[1];
1414
1730
  const s3_1 = patternInput_7[0];
1415
1731
  const s_2 = compose(unify(typeDefs, applyType(s3_1, patternInput_6[1]), tElse, span_5), compose(s3_1, compose(s2_1, compose(sBool, s1_3))));
@@ -1417,23 +1733,23 @@ function inferExpr(typeDefs, constructors, env, expr) {
1417
1733
  return [s_2, tRes_1, asTyped(expr, tRes_1)];
1418
1734
  }
1419
1735
  case 7: {
1420
- const patternInput_8 = inferExpr(typeDefs, constructors, env, expr.fields[0]);
1736
+ const patternInput_8 = inferExpr(telemetry, typeDefs, constructors, env, expr.fields[0]);
1421
1737
  const s1_4 = patternInput_8[0];
1422
- const s_3 = compose(unify(typeDefs, applyType(s1_4, patternInput_8[1]), new Type(4, []), expr.fields[1]), s1_4);
1738
+ const s_3 = compose(unify(typeDefs, applyType(s1_4, patternInput_8[1]), Type.TString, expr.fields[1]), s1_4);
1423
1739
  const tRes_2 = Types_freshVar();
1424
1740
  return [s_3, tRes_2, asTyped(expr, tRes_2)];
1425
1741
  }
1426
1742
  case 8: {
1427
1743
  const name_3 = expr.fields[0];
1428
1744
  const body_1 = expr.fields[2];
1429
- const patternInput_9 = inferExpr(typeDefs, constructors, env, expr.fields[1]);
1745
+ const patternInput_9 = inferExpr(telemetry, typeDefs, constructors, env, expr.fields[1]);
1430
1746
  const s1_5 = patternInput_9[0];
1431
1747
  const tv_2 = Types_freshVar();
1432
- const sSource = compose(unify(typeDefs, applyType(s1_5, patternInput_9[1]), new Type(5, [tv_2]), expr.fields[3]), s1_5);
1748
+ const sSource = compose(unify(typeDefs, applyType(s1_5, patternInput_9[1]), new Type(/* TList */ 5, [tv_2]), expr.fields[3]), s1_5);
1433
1749
  const envBody = add(name_3, new Scheme(empty_2(), applyType(sSource, tv_2)), applyEnv(sSource, env));
1434
- const patternInput_10 = withLocalBindings(singleton(name_3), () => inferExpr(typeDefs, constructors, envBody, body_1));
1750
+ const patternInput_10 = withLocalBindings(telemetry, singleton(name_3), () => inferExpr(telemetry, typeDefs, constructors, envBody, body_1));
1435
1751
  const s2_3 = patternInput_10[0];
1436
- return [compose(unify(typeDefs, applyType(s2_3, patternInput_10[1]), new Type(0, []), Ast_spanOfExpr(body_1)), compose(s2_3, sSource)), new Type(0, []), asTyped(expr, new Type(0, []))];
1752
+ return [compose(unify(typeDefs, applyType(s2_3, patternInput_10[1]), Type.TUnit, Ast_spanOfExpr(body_1)), compose(s2_3, sSource)), Type.TUnit, asTyped(expr, Type.TUnit)];
1437
1753
  }
1438
1754
  case 10: {
1439
1755
  const value_3 = expr.fields[1];
@@ -1444,41 +1760,41 @@ function inferExpr(typeDefs, constructors, env, expr) {
1444
1760
  if (expr.fields[3]) {
1445
1761
  const tv_3 = Types_freshVar();
1446
1762
  const envRec = add(name_4, new Scheme(empty_2(), tv_3), env);
1447
- const patternInput_11 = withLocalBindings(singleton(name_4), () => inferExpr(typeDefs, constructors, envRec, value_3));
1763
+ const patternInput_11 = withLocalBindings(telemetry, singleton(name_4), () => inferExpr(telemetry, typeDefs, constructors, envRec, value_3));
1448
1764
  const t1_2 = patternInput_11[1];
1449
1765
  const s1_6 = patternInput_11[0];
1450
1766
  const s2_4 = unify(typeDefs, applyType(s1_6, tv_3), t1_2, span_8);
1451
1767
  const sValue = compose((returnAnnotation == null) ? emptySubst : ((expectedReturn = annotationTypeFromRef(typeDefs, span_8, returnAnnotation), unify(typeDefs, functionReturnType(applyType(s2_4, t1_2)), expectedReturn, span_8))), compose(s2_4, s1_6));
1452
1768
  const env1 = applyEnv(sValue, env);
1453
1769
  const env2_2 = add(name_4, Types_generalize(env1, applyType(sValue, t1_2)), env1);
1454
- const patternInput_12 = withLocalBindings(singleton(name_4), () => inferExpr(typeDefs, constructors, env2_2, body_2));
1770
+ const patternInput_12 = withLocalBindings(telemetry, singleton(name_4), () => inferExpr(telemetry, typeDefs, constructors, env2_2, body_2));
1455
1771
  const tBody_2 = patternInput_12[1];
1456
1772
  return [compose(patternInput_12[0], sValue), tBody_2, asTyped(expr, tBody_2)];
1457
1773
  }
1458
1774
  else {
1459
- const patternInput_13 = inferExpr(typeDefs, constructors, env, value_3);
1775
+ const patternInput_13 = inferExpr(telemetry, typeDefs, constructors, env, value_3);
1460
1776
  const t1_3 = patternInput_13[1];
1461
1777
  const s1_7 = patternInput_13[0];
1462
- const sDiscard = (name_4 === "_") ? unify(typeDefs, applyType(s1_7, t1_3), new Type(0, []), Ast_spanOfExpr(value_3)) : emptySubst;
1778
+ const sDiscard = (name_4 === "_") ? unify(typeDefs, applyType(s1_7, t1_3), Type.TUnit, Ast_spanOfExpr(value_3)) : emptySubst;
1463
1779
  const sValue_1 = compose((returnAnnotation == null) ? emptySubst : ((expectedReturn_1 = annotationTypeFromRef(typeDefs, span_8, returnAnnotation), unify(typeDefs, functionReturnType(applyType(sDiscard, t1_3)), expectedReturn_1, span_8))), compose(sDiscard, s1_7));
1464
1780
  const env1_1 = applyEnv(sValue_1, env);
1465
1781
  const env2_3 = add(name_4, Types_generalize(env1_1, applyType(sValue_1, t1_3)), env1_1);
1466
- const patternInput_14 = withLocalBindings(singleton(name_4), () => inferExpr(typeDefs, constructors, env2_3, body_2));
1782
+ const patternInput_14 = withLocalBindings(telemetry, singleton(name_4), () => inferExpr(telemetry, typeDefs, constructors, env2_3, body_2));
1467
1783
  const t2_1 = patternInput_14[1];
1468
1784
  return [compose(patternInput_14[0], sValue_1), t2_1, asTyped(expr, t2_1)];
1469
1785
  }
1470
1786
  }
1471
1787
  case 11: {
1472
- const startIndex = currentTelemetryCaptureCount() | 0;
1473
- const patternInput_15 = inferExpr(typeDefs, constructors, env, expr.fields[1]);
1788
+ const startIndex = currentTelemetryCaptureCount(telemetry) | 0;
1789
+ const patternInput_15 = inferExpr(telemetry, typeDefs, constructors, env, expr.fields[1]);
1474
1790
  const s1_8 = patternInput_15[0];
1475
- const patternInput_16 = inferPattern(typeDefs, constructors, expr.fields[0]);
1791
+ const patternInput_16 = inferPattern(telemetry, typeDefs, constructors, expr.fields[0]);
1476
1792
  const sValue_2 = compose(unify(typeDefs, applyType(s1_8, patternInput_15[1]), patternInput_16[1], expr.fields[3]), s1_8);
1477
- applySubstToCapturedLocals(startIndex, sValue_2);
1793
+ applySubstToCapturedLocals(telemetry, startIndex, sValue_2);
1478
1794
  const env1_2 = applyEnv(sValue_2, env);
1479
1795
  const envPatTyped = map_1((_arg, ty) => applyType(sValue_2, ty), patternInput_16[0]);
1480
1796
  const env2_4 = fold_1((state, name_5, bindingType) => add(name_5, Types_generalize(env1_2, bindingType), state), env1_2, envPatTyped);
1481
- const patternInput_17 = withLocalBindings(map((tuple) => tuple[0], toList(envPatTyped)), () => inferExpr(typeDefs, constructors, env2_4, expr.fields[2]));
1797
+ const patternInput_17 = withLocalBindings(telemetry, map((tuple) => tuple[0], toList(envPatTyped)), () => inferExpr(telemetry, typeDefs, constructors, env2_4, expr.fields[2]));
1482
1798
  const tBody_3 = patternInput_17[1];
1483
1799
  return [compose(patternInput_17[0], sValue_2), tBody_3, asTyped(expr, tBody_3)];
1484
1800
  }
@@ -1486,10 +1802,10 @@ function inferExpr(typeDefs, constructors, env, expr) {
1486
1802
  const foldedBindings = map((tupledArg) => {
1487
1803
  const args = tupledArg[1];
1488
1804
  const bindingSpan = tupledArg[4];
1489
- if (isEmpty(args)) {
1805
+ if (isEmpty_1(args)) {
1490
1806
  throw new TypeException(new TypeError$("\'let rec ... and ...\' requires function arguments for each binding", bindingSpan));
1491
1807
  }
1492
- return [tupledArg[0], tupledArg[2], foldBack((arg_4, acc) => (new Expr(4, [arg_4, acc, bindingSpan])), args, tupledArg[3]), bindingSpan];
1808
+ return [tupledArg[0], tupledArg[2], foldBack((arg_4, acc) => (new Expr(/* ELambda */ 4, [arg_4, acc, bindingSpan])), args, tupledArg[3]), bindingSpan];
1493
1809
  }, expr.fields[0]);
1494
1810
  const freshByName = ofList(map((tupledArg_1) => [tupledArg_1[0], Types_freshVar()], foldedBindings), {
1495
1811
  Compare: (x, y) => (comparePrimitives(x, y) | 0),
@@ -1497,12 +1813,12 @@ function inferExpr(typeDefs, constructors, env, expr) {
1497
1813
  const envRec_1 = fold_1((acc_1, name_8, tv_4) => add(name_8, new Scheme(empty_2(), tv_4), acc_1), env, freshByName);
1498
1814
  let sRec = emptySubst;
1499
1815
  const recursiveNames = map((tuple_1) => tuple_1[0], toList(freshByName));
1500
- withLocalBindings(recursiveNames, () => {
1816
+ withLocalBindings(telemetry, recursiveNames, () => {
1501
1817
  const enumerator_1 = getEnumerator(foldedBindings);
1502
1818
  try {
1503
1819
  while (enumerator_1["System.Collections.IEnumerator.MoveNext"]()) {
1504
1820
  const forLoopVar = enumerator_1["System.Collections.Generic.IEnumerator`1.get_Current"]();
1505
- const patternInput_18 = inferExpr(typeDefs, constructors, applyEnv(sRec, envRec_1), forLoopVar[2]);
1821
+ const patternInput_18 = inferExpr(telemetry, typeDefs, constructors, applyEnv(sRec, envRec_1), forLoopVar[2]);
1506
1822
  const s1_9 = patternInput_18[0];
1507
1823
  const s2_7 = unify(typeDefs, applyType(s1_9, applyType(sRec, FSharpMap__get_Item(freshByName, forLoopVar[0]))), patternInput_18[1], forLoopVar[3]);
1508
1824
  sRec = compose(s2_7, compose(s1_9, sRec));
@@ -1535,12 +1851,12 @@ function inferExpr(typeDefs, constructors, env, expr) {
1535
1851
  const name_11 = tupledArg_2[0];
1536
1852
  return [name_11, Types_generalize(envGeneralize, applyType(sRec, FSharpMap__get_Item(freshByName, name_11)))];
1537
1853
  }, foldedBindings));
1538
- const patternInput_19 = withLocalBindings(recursiveNames, () => inferExpr(typeDefs, constructors, envBody_1, expr.fields[1]));
1854
+ const patternInput_19 = withLocalBindings(telemetry, recursiveNames, () => inferExpr(telemetry, typeDefs, constructors, envBody_1, expr.fields[1]));
1539
1855
  const tBody_4 = patternInput_19[1];
1540
1856
  return [compose(patternInput_19[0], sRec), tBody_4, asTyped(expr, tBody_4)];
1541
1857
  }
1542
1858
  case 9: {
1543
- const patternInput_20 = inferExpr(typeDefs, constructors, env, expr.fields[0]);
1859
+ const patternInput_20 = inferExpr(telemetry, typeDefs, constructors, env, expr.fields[0]);
1544
1860
  const tScrut = patternInput_20[1];
1545
1861
  let sAcc_1 = patternInput_20[0];
1546
1862
  let resultTypeOpt = undefined;
@@ -1552,7 +1868,7 @@ function inferExpr(typeDefs, constructors, env, expr) {
1552
1868
  const pat_1 = forLoopVar_2[0];
1553
1869
  const guard = forLoopVar_2[1];
1554
1870
  const caseSpan = forLoopVar_2[3];
1555
- const patternInput_21 = inferPattern(typeDefs, constructors, pat_1);
1871
+ const patternInput_21 = inferPattern(telemetry, typeDefs, constructors, pat_1);
1556
1872
  const tPat_1 = patternInput_21[1];
1557
1873
  const envPat_1 = patternInput_21[0];
1558
1874
  let sPat;
@@ -1643,19 +1959,19 @@ function inferExpr(typeDefs, constructors, env, expr) {
1643
1959
  sPat = unify(typeDefs, applyType(sAcc_1, tScrut), tPat_1, caseSpan);
1644
1960
  }
1645
1961
  const envCase$0027 = fold_1((acc_3, k, v) => add(k, new Scheme(empty_2(), applyType(sPat, v)), acc_3), applyEnv(compose(sPat, sAcc_1), env), envPat_1);
1646
- const patternInput_23 = withLocalBindings(map((tuple_2) => tuple_2[0], toList(envPat_1)), () => {
1962
+ const patternInput_23 = withLocalBindings(telemetry, map((tuple_2) => tuple_2[0], toList(envPat_1)), () => {
1647
1963
  let envBodyCase = envCase$0027;
1648
1964
  if (guard == null) {
1649
1965
  }
1650
1966
  else {
1651
1967
  const guardExpr = guard;
1652
- const patternInput_22 = inferExpr(typeDefs, constructors, envBodyCase, guardExpr);
1968
+ const patternInput_22 = inferExpr(telemetry, typeDefs, constructors, envBodyCase, guardExpr);
1653
1969
  const sGuard = patternInput_22[0];
1654
- const sGuardBool = unify(typeDefs, applyType(sGuard, patternInput_22[1]), new Type(3, []), caseSpan);
1970
+ const sGuardBool = unify(typeDefs, applyType(sGuard, patternInput_22[1]), Type.TBool, caseSpan);
1655
1971
  sAcc_1 = compose(sGuardBool, compose(sGuard, sAcc_1));
1656
1972
  envBodyCase = applyEnv(compose(sGuardBool, sGuard), envBodyCase);
1657
1973
  }
1658
- return inferExpr(typeDefs, constructors, envBodyCase, forLoopVar_2[2]);
1974
+ return inferExpr(telemetry, typeDefs, constructors, envBodyCase, forLoopVar_2[2]);
1659
1975
  });
1660
1976
  const sBody_2 = patternInput_23[0];
1661
1977
  const tBody$0027 = applyType(sBody_2, patternInput_23[1]);
@@ -1676,7 +1992,7 @@ function inferExpr(typeDefs, constructors, env, expr) {
1676
1992
  try {
1677
1993
  while (enumerator_4["System.Collections.IEnumerator.MoveNext"]()) {
1678
1994
  const item = enumerator_4["System.Collections.Generic.IEnumerator`1.get_Current"]();
1679
- const patternInput_24 = inferExpr(typeDefs, constructors, applyEnv(sAcc_2, env), item);
1995
+ const patternInput_24 = inferExpr(telemetry, typeDefs, constructors, applyEnv(sAcc_2, env), item);
1680
1996
  const s1_11 = patternInput_24[0];
1681
1997
  const s2_8 = unify(typeDefs, applyType(s1_11, tv_5), patternInput_24[1], expr.fields[1]);
1682
1998
  sAcc_2 = compose(s2_8, compose(s1_11, sAcc_2));
@@ -1685,18 +2001,18 @@ function inferExpr(typeDefs, constructors, env, expr) {
1685
2001
  finally {
1686
2002
  disposeSafe(enumerator_4);
1687
2003
  }
1688
- const tRes_4 = new Type(5, [applyType(sAcc_2, tv_5)]);
2004
+ const tRes_4 = new Type(/* TList */ 5, [applyType(sAcc_2, tv_5)]);
1689
2005
  return [sAcc_2, tRes_4, asTyped(expr, tRes_4)];
1690
2006
  }
1691
2007
  case 14: {
1692
2008
  const span_13 = expr.fields[2];
1693
- const patternInput_25 = inferExpr(typeDefs, constructors, env, expr.fields[0]);
2009
+ const patternInput_25 = inferExpr(telemetry, typeDefs, constructors, env, expr.fields[0]);
1694
2010
  const s1_12 = patternInput_25[0];
1695
- const patternInput_26 = inferExpr(typeDefs, constructors, applyEnv(s1_12, env), expr.fields[1]);
2011
+ const patternInput_26 = inferExpr(telemetry, typeDefs, constructors, applyEnv(s1_12, env), expr.fields[1]);
1696
2012
  const s2_9 = patternInput_26[0];
1697
- const s3_3 = unify(typeDefs, applyType(s2_9, patternInput_25[1]), new Type(1, []), span_13);
1698
- const tRes_5 = new Type(5, [new Type(1, [])]);
1699
- return [compose(unify(typeDefs, applyType(s3_3, applyType(s2_9, patternInput_26[1])), new Type(1, []), span_13), compose(s3_3, compose(s2_9, s1_12))), tRes_5, asTyped(expr, tRes_5)];
2013
+ const s3_3 = unify(typeDefs, applyType(s2_9, patternInput_25[1]), Type.TInt, span_13);
2014
+ const tRes_5 = new Type(/* TList */ 5, [Type.TInt]);
2015
+ return [compose(unify(typeDefs, applyType(s3_3, applyType(s2_9, patternInput_26[1])), Type.TInt, span_13), compose(s3_3, compose(s2_9, s1_12))), tRes_5, asTyped(expr, tRes_5)];
1700
2016
  }
1701
2017
  case 15: {
1702
2018
  let sAcc_3 = emptySubst;
@@ -1705,7 +2021,7 @@ function inferExpr(typeDefs, constructors, env, expr) {
1705
2021
  try {
1706
2022
  while (enumerator_5["System.Collections.IEnumerator.MoveNext"]()) {
1707
2023
  const item_1 = enumerator_5["System.Collections.Generic.IEnumerator`1.get_Current"]();
1708
- const patternInput_27 = inferExpr(typeDefs, constructors, applyEnv(sAcc_3, env), item_1);
2024
+ const patternInput_27 = inferExpr(telemetry, typeDefs, constructors, applyEnv(sAcc_3, env), item_1);
1709
2025
  sAcc_3 = compose(patternInput_27[0], sAcc_3);
1710
2026
  inferred_1 = append(inferred_1, singleton(applyType(sAcc_3, patternInput_27[1])));
1711
2027
  }
@@ -1713,7 +2029,7 @@ function inferExpr(typeDefs, constructors, env, expr) {
1713
2029
  finally {
1714
2030
  disposeSafe(enumerator_5);
1715
2031
  }
1716
- const tRes_6 = new Type(7, [inferred_1]);
2032
+ const tRes_6 = new Type(/* TTuple */ 7, [inferred_1]);
1717
2033
  return [sAcc_3, tRes_6, asTyped(expr, tRes_6)];
1718
2034
  }
1719
2035
  case 16: {
@@ -1726,7 +2042,7 @@ function inferExpr(typeDefs, constructors, env, expr) {
1726
2042
  try {
1727
2043
  while (enumerator_6["System.Collections.IEnumerator.MoveNext"]()) {
1728
2044
  const forLoopVar_3 = enumerator_6["System.Collections.Generic.IEnumerator`1.get_Current"]();
1729
- const patternInput_28 = inferExpr(typeDefs, constructors, applyEnv(sAcc_4, env), forLoopVar_3[1]);
2045
+ const patternInput_28 = inferExpr(telemetry, typeDefs, constructors, applyEnv(sAcc_4, env), forLoopVar_3[1]);
1730
2046
  sAcc_4 = compose(patternInput_28[0], sAcc_4);
1731
2047
  inferred_2 = FSharpMap__Add(inferred_2, forLoopVar_3[0], applyType(sAcc_4, patternInput_28[1]));
1732
2048
  }
@@ -1734,10 +2050,10 @@ function inferExpr(typeDefs, constructors, env, expr) {
1734
2050
  finally {
1735
2051
  disposeSafe(enumerator_6);
1736
2052
  }
1737
- const expected_1 = new Type(12, [resolveNamedRecordByFieldSet(typeDefs, ofSeq(keys(inferred_2), {
2053
+ const expected_1 = new Type(/* TNamed */ 12, [resolveNamedRecordByFieldSet(typeDefs, ofSeq(keys(inferred_2), {
1738
2054
  Compare: (x_2, y_2) => (comparePrimitives(x_2, y_2) | 0),
1739
2055
  }), span_14)]);
1740
- const s_10 = compose(unify(typeDefs, applyType(sAcc_4, new Type(8, [inferred_2])), expected_1, span_14), sAcc_4);
2056
+ const s_10 = compose(unify(typeDefs, applyType(sAcc_4, new Type(/* TRecord */ 8, [inferred_2])), expected_1, span_14), sAcc_4);
1741
2057
  const tRes_7 = applyType(s_10, expected_1);
1742
2058
  return [s_10, tRes_7, asTyped(expr, tRes_7)];
1743
2059
  }
@@ -1750,7 +2066,7 @@ function inferExpr(typeDefs, constructors, env, expr) {
1750
2066
  try {
1751
2067
  while (enumerator_7["System.Collections.IEnumerator.MoveNext"]()) {
1752
2068
  const forLoopVar_4 = enumerator_7["System.Collections.Generic.IEnumerator`1.get_Current"]();
1753
- const patternInput_29 = inferExpr(typeDefs, constructors, applyEnv(sAcc_5, env), forLoopVar_4[1]);
2069
+ const patternInput_29 = inferExpr(telemetry, typeDefs, constructors, applyEnv(sAcc_5, env), forLoopVar_4[1]);
1754
2070
  sAcc_5 = compose(patternInput_29[0], sAcc_5);
1755
2071
  inferred_3 = FSharpMap__Add(inferred_3, forLoopVar_4[0], applyType(sAcc_5, patternInput_29[1]));
1756
2072
  }
@@ -1758,7 +2074,7 @@ function inferExpr(typeDefs, constructors, env, expr) {
1758
2074
  finally {
1759
2075
  disposeSafe(enumerator_7);
1760
2076
  }
1761
- const tRes_8 = new Type(8, [inferred_3]);
2077
+ const tRes_8 = new Type(/* TRecord */ 8, [inferred_3]);
1762
2078
  return [sAcc_5, tRes_8, asTyped(expr, tRes_8)];
1763
2079
  }
1764
2080
  case 18: {
@@ -1781,20 +2097,20 @@ function inferExpr(typeDefs, constructors, env, expr) {
1781
2097
  const entry = enumerator_8["System.Collections.Generic.IEnumerator`1.get_Current"]();
1782
2098
  if (entry.tag === 1) {
1783
2099
  const spreadExpr = entry.fields[0];
1784
- const patternInput_32 = inferExpr(typeDefs, constructors, applyEnv(sAcc_6, env), spreadExpr);
2100
+ const patternInput_32 = inferExpr(telemetry, typeDefs, constructors, applyEnv(sAcc_6, env), spreadExpr);
1785
2101
  const sSpread = patternInput_32[0];
1786
- const expectedSpreadType = new Type(9, [applyType(sSpread, applyType(sAcc_6, keyType)), applyType(sSpread, applyType(sAcc_6, valueType))]);
2102
+ const expectedSpreadType = new Type(/* TMap */ 9, [applyType(sSpread, applyType(sAcc_6, keyType)), applyType(sSpread, applyType(sAcc_6, valueType))]);
1787
2103
  const sSpreadMap = unify(typeDefs, applyType(sSpread, patternInput_32[1]), expectedSpreadType, Ast_spanOfExpr(spreadExpr));
1788
2104
  sAcc_6 = compose(sSpreadMap, compose(sSpread, sAcc_6));
1789
2105
  }
1790
2106
  else {
1791
2107
  const valueExpr_3 = entry.fields[1];
1792
2108
  const keyExpr = entry.fields[0];
1793
- const patternInput_30 = inferExpr(typeDefs, constructors, applyEnv(sAcc_6, env), keyExpr);
2109
+ const patternInput_30 = inferExpr(telemetry, typeDefs, constructors, applyEnv(sAcc_6, env), keyExpr);
1794
2110
  const sKey = patternInput_30[0];
1795
2111
  const sAfterKey = compose(unify(typeDefs, applyType(sKey, patternInput_30[1]), applyType(sKey, applyType(sAcc_6, keyType)), Ast_spanOfExpr(keyExpr)), compose(sKey, sAcc_6));
1796
2112
  ensureSupportedMapKeyType(applyType(sAfterKey, keyType));
1797
- const patternInput_31 = inferExpr(typeDefs, constructors, applyEnv(sAfterKey, env), valueExpr_3);
2113
+ const patternInput_31 = inferExpr(telemetry, typeDefs, constructors, applyEnv(sAfterKey, env), valueExpr_3);
1798
2114
  const sValue_3 = patternInput_31[0];
1799
2115
  const sValueType = unify(typeDefs, applyType(sValue_3, applyType(sAfterKey, valueType)), patternInput_31[1], Ast_spanOfExpr(valueExpr_3));
1800
2116
  sAcc_6 = compose(sValueType, compose(sValue_3, sAfterKey));
@@ -1805,12 +2121,12 @@ function inferExpr(typeDefs, constructors, env, expr) {
1805
2121
  disposeSafe(enumerator_8);
1806
2122
  }
1807
2123
  ensureSupportedMapKeyType(applyType(sAcc_6, keyType));
1808
- const tRes_9 = new Type(9, [applyType(sAcc_6, keyType), applyType(sAcc_6, valueType)]);
2124
+ const tRes_9 = new Type(/* TMap */ 9, [applyType(sAcc_6, keyType), applyType(sAcc_6, valueType)]);
1809
2125
  return [sAcc_6, tRes_9, asTyped(expr, tRes_9)];
1810
2126
  }
1811
2127
  case 19: {
1812
2128
  const span_16 = expr.fields[2];
1813
- const patternInput_33 = inferExpr(typeDefs, constructors, env, expr.fields[0]);
2129
+ const patternInput_33 = inferExpr(telemetry, typeDefs, constructors, env, expr.fields[0]);
1814
2130
  const sBase = patternInput_33[0];
1815
2131
  let baseFields;
1816
2132
  const matchValue_7 = applyType(sBase, patternInput_33[1]);
@@ -1862,7 +2178,7 @@ function inferExpr(typeDefs, constructors, env, expr) {
1862
2178
  else {
1863
2179
  expectedFieldType = matchValue_9;
1864
2180
  }
1865
- const patternInput_34 = inferExpr(typeDefs, constructors, applyEnv(sAcc_7, env), valueExpr_4);
2181
+ const patternInput_34 = inferExpr(telemetry, typeDefs, constructors, applyEnv(sAcc_7, env), valueExpr_4);
1866
2182
  const sField_2 = patternInput_34[0];
1867
2183
  const sEq_1 = unify(typeDefs, applyType(sField_2, applyType(sAcc_7, expectedFieldType)), patternInput_34[1], Ast_spanOfExpr(valueExpr_4));
1868
2184
  sAcc_7 = compose(sEq_1, compose(sField_2, sAcc_7));
@@ -1871,12 +2187,12 @@ function inferExpr(typeDefs, constructors, env, expr) {
1871
2187
  finally {
1872
2188
  disposeSafe(enumerator_9);
1873
2189
  }
1874
- const tRes_10 = new Type(8, [map_1((_arg_7, t_5) => applyType(sAcc_7, t_5), baseFields)]);
2190
+ const tRes_10 = new Type(/* TRecord */ 8, [map_1((_arg_7, t_5) => applyType(sAcc_7, t_5), baseFields)]);
1875
2191
  return [sAcc_7, tRes_10, asTyped(expr, tRes_10)];
1876
2192
  }
1877
2193
  case 20: {
1878
2194
  const span_17 = expr.fields[2];
1879
- const patternInput_35 = inferExpr(typeDefs, constructors, env, expr.fields[0]);
2195
+ const patternInput_35 = inferExpr(telemetry, typeDefs, constructors, env, expr.fields[0]);
1880
2196
  const sBase_1 = patternInput_35[0];
1881
2197
  let sAcc_8 = sBase_1;
1882
2198
  let resultFields_1;
@@ -1921,7 +2237,7 @@ function inferExpr(typeDefs, constructors, env, expr) {
1921
2237
  const forLoopVar_6 = enumerator_10["System.Collections.Generic.IEnumerator`1.get_Current"]();
1922
2238
  const valueExpr_5 = forLoopVar_6[1];
1923
2239
  const name_18 = forLoopVar_6[0];
1924
- const patternInput_36 = inferExpr(typeDefs, constructors, applyEnv(sAcc_8, env), valueExpr_5);
2240
+ const patternInput_36 = inferExpr(telemetry, typeDefs, constructors, applyEnv(sAcc_8, env), valueExpr_5);
1925
2241
  const sField_3 = patternInput_36[0];
1926
2242
  const tFieldApplied = applyType(sField_3, patternInput_36[1]);
1927
2243
  const sEq_2 = unify(typeDefs, (matchValue_12 = FSharpMap__TryFind(resultFields_1, name_18), (matchValue_12 == null) ? tFieldApplied : ((existingFieldType = matchValue_12, applyType(sField_3, applyType(sAcc_8, existingFieldType))))), tFieldApplied, Ast_spanOfExpr(valueExpr_5));
@@ -1932,7 +2248,7 @@ function inferExpr(typeDefs, constructors, env, expr) {
1932
2248
  finally {
1933
2249
  disposeSafe(enumerator_10);
1934
2250
  }
1935
- const tRes_11 = new Type(8, [map_1((_arg_8, t_6) => applyType(sAcc_8, t_6), resultFields_1)]);
2251
+ const tRes_11 = new Type(/* TRecord */ 8, [map_1((_arg_8, t_6) => applyType(sAcc_8, t_6), resultFields_1)]);
1936
2252
  return [sAcc_8, tRes_11, asTyped(expr, tRes_11)];
1937
2253
  }
1938
2254
  case 21: {
@@ -1982,7 +2298,7 @@ function inferExpr(typeDefs, constructors, env, expr) {
1982
2298
  }
1983
2299
  case 15: {
1984
2300
  const tField_4 = Types_freshVar();
1985
- const s_11 = compose(unify(typeDefs, matchValue_13, new Type(8, [ofList(singleton([fieldName, tField_4]), {
2301
+ const s_11 = compose(unify(typeDefs, matchValue_13, new Type(/* TRecord */ 8, [ofList(singleton([fieldName, tField_4]), {
1986
2302
  Compare: (x_4, y_4) => (comparePrimitives(x_4, y_4) | 0),
1987
2303
  })]), span_18), s1_16);
1988
2304
  return [s_11, applyType(s_11, tField_4)];
@@ -2008,7 +2324,7 @@ function inferExpr(typeDefs, constructors, env, expr) {
2008
2324
  case 0: {
2009
2325
  const matchValue_17 = FSharpMap__TryFind(env, concat(moduleName_1, ".", fieldName));
2010
2326
  if (matchValue_17 == null) {
2011
- const patternInput_37 = inferExpr(typeDefs, constructors, env, target);
2327
+ const patternInput_37 = inferExpr(telemetry, typeDefs, constructors, env, target);
2012
2328
  const patternInput_38 = inferRecordField(patternInput_37[0], patternInput_37[1]);
2013
2329
  const tField_5 = patternInput_38[1];
2014
2330
  return [patternInput_38[0], tField_5, asTyped(expr, tField_5)];
@@ -2019,7 +2335,7 @@ function inferExpr(typeDefs, constructors, env, expr) {
2019
2335
  }
2020
2336
  }
2021
2337
  default: {
2022
- const patternInput_39 = inferExpr(typeDefs, constructors, env, target);
2338
+ const patternInput_39 = inferExpr(telemetry, typeDefs, constructors, env, target);
2023
2339
  const patternInput_40 = inferRecordField(patternInput_39[0], patternInput_39[1]);
2024
2340
  const tField_6 = patternInput_40[1];
2025
2341
  return [patternInput_40[0], tField_6, asTyped(expr, tField_6)];
@@ -2028,9 +2344,9 @@ function inferExpr(typeDefs, constructors, env, expr) {
2028
2344
  }
2029
2345
  case 22: {
2030
2346
  const span_19 = expr.fields[2];
2031
- const patternInput_41 = inferExpr(typeDefs, constructors, env, expr.fields[0]);
2347
+ const patternInput_41 = inferExpr(telemetry, typeDefs, constructors, env, expr.fields[0]);
2032
2348
  const s1_19 = patternInput_41[0];
2033
- const patternInput_42 = inferExpr(typeDefs, constructors, applyEnv(s1_19, env), expr.fields[1]);
2349
+ const patternInput_42 = inferExpr(telemetry, typeDefs, constructors, applyEnv(s1_19, env), expr.fields[1]);
2034
2350
  const s2_10 = patternInput_42[0];
2035
2351
  const targetType = applyType(s2_10, patternInput_41[1]);
2036
2352
  const keyType_1 = applyType(s2_10, patternInput_42[1]);
@@ -2071,8 +2387,8 @@ function inferExpr(typeDefs, constructors, env, expr) {
2071
2387
  }
2072
2388
  switch (matchResult_6) {
2073
2389
  case 0: {
2074
- const s_12 = compose(unify(typeDefs, keyType_1, new Type(1, []), span_19), compose(s2_10, s1_19));
2075
- const tRes_12 = new Type(10, [applyType(s_12, itemType_1)]);
2390
+ const s_12 = compose(unify(typeDefs, keyType_1, Type.TInt, span_19), compose(s2_10, s1_19));
2391
+ const tRes_12 = new Type(/* TOption */ 10, [applyType(s_12, itemType_1)]);
2076
2392
  return [s_12, tRes_12, asTyped(expr, tRes_12)];
2077
2393
  }
2078
2394
  case 1: {
@@ -2086,19 +2402,19 @@ function inferExpr(typeDefs, constructors, env, expr) {
2086
2402
  default:
2087
2403
  throw new TypeException(new TypeError$(concat("Map key type must be string, got ", Types_typeToString(matchValue_19)), span_19));
2088
2404
  }
2089
- const tRes_13 = new Type(10, [applyType(s_13, valueType_1)]);
2405
+ const tRes_13 = new Type(/* TOption */ 10, [applyType(s_13, valueType_1)]);
2090
2406
  return [s_13, tRes_13, asTyped(expr, tRes_13)];
2091
2407
  }
2092
2408
  case 2: {
2093
2409
  const itemType_2 = Types_freshVar();
2094
- const s_14 = compose(unify(typeDefs, targetType, new Type(5, [itemType_2]), span_19), compose(s2_10, s1_19));
2095
- const tRes_14 = new Type(10, [applyType(s_14, itemType_2)]);
2410
+ const s_14 = compose(unify(typeDefs, targetType, new Type(/* TList */ 5, [itemType_2]), span_19), compose(s2_10, s1_19));
2411
+ const tRes_14 = new Type(/* TOption */ 10, [applyType(s_14, itemType_2)]);
2096
2412
  return [s_14, tRes_14, asTyped(expr, tRes_14)];
2097
2413
  }
2098
2414
  case 3: {
2099
2415
  const valueType_2 = Types_freshVar();
2100
- const s_15 = compose(unify(typeDefs, targetType, new Type(9, [new Type(4, []), valueType_2]), span_19), compose(s2_10, s1_19));
2101
- const tRes_15 = new Type(10, [applyType(s_15, valueType_2)]);
2416
+ const s_15 = compose(unify(typeDefs, targetType, new Type(/* TMap */ 9, [Type.TString, valueType_2]), span_19), compose(s2_10, s1_19));
2417
+ const tRes_15 = new Type(/* TOption */ 10, [applyType(s_15, valueType_2)]);
2102
2418
  return [s_15, tRes_15, asTyped(expr, tRes_15)];
2103
2419
  }
2104
2420
  case 4:
@@ -2114,112 +2430,114 @@ function inferExpr(typeDefs, constructors, env, expr) {
2114
2430
  const a = expr.fields[1];
2115
2431
  switch (op) {
2116
2432
  case "|>": {
2117
- const patternInput_43 = inferExpr(typeDefs, constructors, env, a);
2433
+ const patternInput_43 = inferExpr(telemetry, typeDefs, constructors, env, a);
2118
2434
  const s1_20 = patternInput_43[0];
2119
- const patternInput_44 = inferExpr(typeDefs, constructors, applyEnv(s1_20, env), b);
2435
+ const patternInput_44 = inferExpr(telemetry, typeDefs, constructors, applyEnv(s1_20, env), b);
2120
2436
  const s2_11 = patternInput_44[0];
2121
2437
  const tv_7 = Types_freshVar();
2122
- const s_16 = compose(unify(typeDefs, applyType(s2_11, patternInput_44[1]), new Type(11, [applyType(s2_11, patternInput_43[1]), tv_7]), span_20), compose(s2_11, s1_20));
2438
+ const s_16 = compose(unify(typeDefs, applyType(s2_11, patternInput_44[1]), new Type(/* TFun */ 11, [applyType(s2_11, patternInput_43[1]), tv_7]), span_20), compose(s2_11, s1_20));
2123
2439
  const tRes_16 = applyType(s_16, tv_7);
2124
2440
  return [s_16, tRes_16, asTyped(expr, tRes_16)];
2125
2441
  }
2126
2442
  case "::": {
2127
- const patternInput_45 = inferExpr(typeDefs, constructors, env, a);
2443
+ const patternInput_45 = inferExpr(telemetry, typeDefs, constructors, env, a);
2128
2444
  const tHead = patternInput_45[1];
2129
2445
  const s1_21 = patternInput_45[0];
2130
- const patternInput_46 = inferExpr(typeDefs, constructors, applyEnv(s1_21, env), b);
2446
+ const patternInput_46 = inferExpr(telemetry, typeDefs, constructors, applyEnv(s1_21, env), b);
2131
2447
  const s2_12 = patternInput_46[0];
2132
- const s_17 = compose(unify(typeDefs, applyType(s2_12, patternInput_46[1]), new Type(5, [tHead]), span_20), compose(s2_12, s1_21));
2133
- const tRes_17 = applyType(s_17, new Type(5, [tHead]));
2448
+ const s_17 = compose(unify(typeDefs, applyType(s2_12, patternInput_46[1]), new Type(/* TList */ 5, [tHead]), span_20), compose(s2_12, s1_21));
2449
+ const tRes_17 = applyType(s_17, new Type(/* TList */ 5, [tHead]));
2134
2450
  return [s_17, tRes_17, asTyped(expr, tRes_17)];
2135
2451
  }
2136
2452
  case "@": {
2137
- const patternInput_47 = inferExpr(typeDefs, constructors, env, a);
2453
+ const patternInput_47 = inferExpr(telemetry, typeDefs, constructors, env, a);
2138
2454
  const s1_22 = patternInput_47[0];
2139
- const patternInput_48 = inferExpr(typeDefs, constructors, applyEnv(s1_22, env), b);
2455
+ const patternInput_48 = inferExpr(telemetry, typeDefs, constructors, applyEnv(s1_22, env), b);
2140
2456
  const s2_13 = patternInput_48[0];
2141
2457
  const tv_8 = Types_freshVar();
2142
- const s3_10 = unify(typeDefs, applyType(s2_13, patternInput_47[1]), new Type(5, [tv_8]), span_20);
2143
- const s_18 = compose(unify(typeDefs, applyType(s3_10, applyType(s2_13, patternInput_48[1])), new Type(5, [applyType(s3_10, tv_8)]), span_20), compose(s3_10, compose(s2_13, s1_22)));
2144
- const tRes_18 = new Type(5, [applyType(s_18, tv_8)]);
2458
+ const s3_10 = unify(typeDefs, applyType(s2_13, patternInput_47[1]), new Type(/* TList */ 5, [tv_8]), span_20);
2459
+ const s_18 = compose(unify(typeDefs, applyType(s3_10, applyType(s2_13, patternInput_48[1])), new Type(/* TList */ 5, [applyType(s3_10, tv_8)]), span_20), compose(s3_10, compose(s2_13, s1_22)));
2460
+ const tRes_18 = new Type(/* TList */ 5, [applyType(s_18, tv_8)]);
2145
2461
  return [s_18, tRes_18, asTyped(expr, tRes_18)];
2146
2462
  }
2147
2463
  default: {
2148
- const patternInput_49 = inferExpr(typeDefs, constructors, env, a);
2464
+ const patternInput_49 = inferExpr(telemetry, typeDefs, constructors, env, a);
2149
2465
  const s1_23 = patternInput_49[0];
2150
- const patternInput_50 = inferExpr(typeDefs, constructors, applyEnv(s1_23, env), b);
2466
+ const patternInput_50 = inferExpr(telemetry, typeDefs, constructors, applyEnv(s1_23, env), b);
2151
2467
  const t2_3 = patternInput_50[1];
2152
2468
  const s2_14 = patternInput_50[0];
2153
2469
  const s3_11 = unify(typeDefs, applyType(s2_14, patternInput_49[1]), t2_3, span_20);
2154
2470
  const t_9 = applyType(s3_11, t2_3);
2155
- let resultType;
2471
+ let patternInput_52;
2156
2472
  switch (op) {
2157
2473
  case "+":
2158
2474
  case "-":
2159
2475
  case "*":
2160
- case "/":
2476
+ case "/": {
2477
+ patternInput_52 = constrainNumeric(typeDefs, t_9, span_20);
2478
+ break;
2479
+ }
2161
2480
  case "%": {
2162
- resultType = numericResult(t_9, span_20);
2481
+ patternInput_52 = [unify(typeDefs, t_9, Type.TInt, span_20), Type.TInt];
2163
2482
  break;
2164
2483
  }
2165
2484
  case "=": {
2166
- resultType = (new Type(3, []));
2485
+ patternInput_52 = [emptySubst, Type.TBool];
2167
2486
  break;
2168
2487
  }
2169
2488
  case "<":
2170
2489
  case ">":
2171
2490
  case "<=":
2172
2491
  case ">=": {
2173
- numericResult(t_9, span_20);
2174
- resultType = (new Type(3, []));
2492
+ patternInput_52 = [constrainNumeric(typeDefs, t_9, span_20)[0], Type.TBool];
2175
2493
  break;
2176
2494
  }
2177
2495
  case "&&":
2178
2496
  case "||": {
2179
- unify(typeDefs, t_9, new Type(3, []), span_20);
2180
- resultType = (new Type(3, []));
2497
+ patternInput_52 = [unify(typeDefs, t_9, Type.TBool, span_20), Type.TBool];
2181
2498
  break;
2182
2499
  }
2183
2500
  default:
2184
2501
  throw new TypeException(new TypeError$(toText(printf("Unknown operator %s"))(op), span_20));
2185
2502
  }
2186
- return [compose(s3_11, compose(s2_14, s1_23)), resultType, asTyped(expr, resultType)];
2503
+ const resultType = patternInput_52[1];
2504
+ return [compose(patternInput_52[0], compose(s3_11, compose(s2_14, s1_23))), resultType, asTyped(expr, resultType)];
2187
2505
  }
2188
2506
  }
2189
2507
  }
2190
2508
  case 26: {
2191
- const patternInput_51 = inferExpr(typeDefs, constructors, env, expr.fields[0]);
2192
- const t1_11 = patternInput_51[1];
2193
- return [patternInput_51[0], new Type(10, [t1_11]), asTyped(expr, new Type(10, [t1_11]))];
2509
+ const patternInput_53 = inferExpr(telemetry, typeDefs, constructors, env, expr.fields[0]);
2510
+ const t1_11 = patternInput_53[1];
2511
+ return [patternInput_53[0], new Type(/* TOption */ 10, [t1_11]), asTyped(expr, new Type(/* TOption */ 10, [t1_11]))];
2194
2512
  }
2195
2513
  case 27: {
2196
2514
  const tv_9 = Types_freshVar();
2197
- return [emptySubst, new Type(10, [tv_9]), asTyped(expr, new Type(10, [tv_9]))];
2515
+ return [emptySubst, new Type(/* TOption */ 10, [tv_9]), asTyped(expr, new Type(/* TOption */ 10, [tv_9]))];
2198
2516
  }
2199
2517
  case 23: {
2200
- const patternInput_52 = inferExpr(typeDefs, constructors, env, expr.fields[0]);
2201
- const t1_12 = patternInput_52[1];
2202
- const s1_25 = patternInput_52[0];
2203
- const patternInput_53 = inferExpr(typeDefs, constructors, applyEnv(s1_25, env), expr.fields[1]);
2204
- const s2_15 = patternInput_53[0];
2205
- const s_20 = compose(unify(typeDefs, applyType(s2_15, patternInput_53[1]), new Type(5, [t1_12]), expr.fields[2]), compose(s2_15, s1_25));
2206
- const tRes_19 = applyType(s_20, new Type(5, [t1_12]));
2518
+ const patternInput_54 = inferExpr(telemetry, typeDefs, constructors, env, expr.fields[0]);
2519
+ const t1_12 = patternInput_54[1];
2520
+ const s1_25 = patternInput_54[0];
2521
+ const patternInput_55 = inferExpr(telemetry, typeDefs, constructors, applyEnv(s1_25, env), expr.fields[1]);
2522
+ const s2_15 = patternInput_55[0];
2523
+ const s_20 = compose(unify(typeDefs, applyType(s2_15, patternInput_55[1]), new Type(/* TList */ 5, [t1_12]), expr.fields[2]), compose(s2_15, s1_25));
2524
+ const tRes_19 = applyType(s_20, new Type(/* TList */ 5, [t1_12]));
2207
2525
  return [s_20, tRes_19, asTyped(expr, tRes_19)];
2208
2526
  }
2209
2527
  case 24: {
2210
2528
  const span_22 = expr.fields[2];
2211
- const patternInput_54 = inferExpr(typeDefs, constructors, env, expr.fields[0]);
2212
- const s1_26 = patternInput_54[0];
2213
- const patternInput_55 = inferExpr(typeDefs, constructors, applyEnv(s1_26, env), expr.fields[1]);
2214
- const s2_16 = patternInput_55[0];
2529
+ const patternInput_56 = inferExpr(telemetry, typeDefs, constructors, env, expr.fields[0]);
2530
+ const s1_26 = patternInput_56[0];
2531
+ const patternInput_57 = inferExpr(telemetry, typeDefs, constructors, applyEnv(s1_26, env), expr.fields[1]);
2532
+ const s2_16 = patternInput_57[0];
2215
2533
  const tv_10 = Types_freshVar();
2216
- const s3_13 = unify(typeDefs, applyType(s2_16, patternInput_54[1]), new Type(5, [tv_10]), span_22);
2217
- const s_21 = compose(unify(typeDefs, applyType(s3_13, applyType(s2_16, patternInput_55[1])), new Type(5, [applyType(s3_13, tv_10)]), span_22), compose(s3_13, compose(s2_16, s1_26)));
2218
- const tRes_20 = new Type(5, [applyType(s_21, tv_10)]);
2534
+ const s3_13 = unify(typeDefs, applyType(s2_16, patternInput_56[1]), new Type(/* TList */ 5, [tv_10]), span_22);
2535
+ const s_21 = compose(unify(typeDefs, applyType(s3_13, applyType(s2_16, patternInput_57[1])), new Type(/* TList */ 5, [applyType(s3_13, tv_10)]), span_22), compose(s3_13, compose(s2_16, s1_26)));
2536
+ const tRes_20 = new Type(/* TList */ 5, [applyType(s_21, tv_10)]);
2219
2537
  return [s_21, tRes_20, asTyped(expr, tRes_20)];
2220
2538
  }
2221
2539
  default:
2222
- return [emptySubst, new Type(0, []), asTyped(expr, new Type(0, []))];
2540
+ return [emptySubst, Type.TUnit, asTyped(expr, Type.TUnit)];
2223
2541
  }
2224
2542
  }
2225
2543
 
@@ -2296,7 +2614,7 @@ function topLevelBindingNames(program) {
2296
2614
  }, program);
2297
2615
  }
2298
2616
 
2299
- function inferProgramWithExternsRawAndLocals(externs, program) {
2617
+ function inferProgramWithExternsRawAndLocals(captureLocalVariables, externs, program) {
2300
2618
  const decls = ofList(append(map((d) => [d.Name, d], typeDefs_1), choose((_arg) => {
2301
2619
  if (_arg.tag === 0) {
2302
2620
  const d_1 = _arg.fields[0];
@@ -2309,13 +2627,16 @@ function inferProgramWithExternsRawAndLocals(externs, program) {
2309
2627
  Compare: (x, y) => (comparePrimitives(x, y) | 0),
2310
2628
  });
2311
2629
  const typeDefs = map_1((name, d_2) => {
2312
- if (!isEmpty(d_2.Cases)) {
2313
- return new Type(13, [name, ofList(map((tupledArg) => [tupledArg[0], map_3((tref) => typeFromRef(decls, singleton(name), tref), tupledArg[1])], d_2.Cases), {
2630
+ if (!isEmpty_1(d_2.Cases)) {
2631
+ return new Type(/* TUnion */ 13, [name, ofList(map((tupledArg) => {
2632
+ let option_1;
2633
+ return [tupledArg[0], (option_1 = tupledArg[1], (option_1 != null) ? typeFromRef(decls, singleton(name), option_1) : undefined)];
2634
+ }, d_2.Cases), {
2314
2635
  Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
2315
2636
  })]);
2316
2637
  }
2317
2638
  else {
2318
- return new Type(8, [ofList(map((tupledArg_1) => [tupledArg_1[0], typeFromRef(decls, singleton(d_2.Name), tupledArg_1[1])], d_2.Fields), {
2639
+ return new Type(/* TRecord */ 8, [ofList(map((tupledArg_1) => [tupledArg_1[0], typeFromRef(decls, singleton(d_2.Name), tupledArg_1[1])], d_2.Fields), {
2319
2640
  Compare: (x_2, y_2) => (comparePrimitives(x_2, y_2) | 0),
2320
2641
  })]);
2321
2642
  }
@@ -2323,8 +2644,9 @@ function inferProgramWithExternsRawAndLocals(externs, program) {
2323
2644
  const constructors = ofList(collect((tupledArg_2) => {
2324
2645
  const typeName = tupledArg_2[0];
2325
2646
  return collect((tupledArg_3) => {
2647
+ let option_3;
2326
2648
  const caseName_1 = tupledArg_3[0];
2327
- const sigInfo = new ConstructorSig(typeName, map_3((tref_1) => typeFromRef(decls, singleton(typeName), tref_1), tupledArg_3[1]));
2649
+ const sigInfo = new ConstructorSig(typeName, (option_3 = tupledArg_3[1], (option_3 != null) ? typeFromRef(decls, singleton(typeName), option_3) : undefined));
2328
2650
  return ofArray([[caseName_1, sigInfo], [concat(typeName, ".", caseName_1), sigInfo]]);
2329
2651
  }, tupledArg_2[1].Cases);
2330
2652
  }, toList(decls)), {
@@ -2333,13 +2655,13 @@ function inferProgramWithExternsRawAndLocals(externs, program) {
2333
2655
  const constructorSchemes = map((tupledArg_4) => {
2334
2656
  let matchValue;
2335
2657
  const sigInfo_1 = tupledArg_4[1];
2336
- const unionType = new Type(12, [sigInfo_1.UnionName]);
2337
- return [tupledArg_4[0], new Scheme(empty_2(), (matchValue = sigInfo_1.Payload, (matchValue != null) ? (new Type(11, [matchValue, unionType])) : unionType))];
2658
+ const unionType = new Type(/* TNamed */ 12, [sigInfo_1.UnionName]);
2659
+ return [tupledArg_4[0], new Scheme(empty_2(), (matchValue = sigInfo_1.Payload, (matchValue != null) ? (new Type(/* TFun */ 11, [matchValue, unionType])) : unionType))];
2338
2660
  }, toList(constructors));
2339
2661
  let env = fold((acc, tupledArg_5) => FSharpMap__Add(acc, tupledArg_5[0], tupledArg_5[1]), envFromExterns(externs), constructorSchemes);
2340
- beginTelemetry();
2662
+ const telemetry = captureLocalVariables ? createTelemetry() : undefined;
2663
+ const typed = [];
2341
2664
  try {
2342
- const typed = [];
2343
2665
  const enumerator = getEnumerator(indexed(program));
2344
2666
  try {
2345
2667
  while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
@@ -2356,7 +2678,7 @@ function inferProgramWithExternsRawAndLocals(externs, program) {
2356
2678
  const returnAnnotation = stmt.fields[2];
2357
2679
  const name_2 = stmt.fields[0];
2358
2680
  const isExported = stmt.fields[5];
2359
- const exprVal = foldBack((arg, acc_1) => (new Expr(4, [arg, acc_1, span_1])), stmt.fields[1], stmt.fields[3]);
2681
+ const exprVal = foldBack((arg, acc_1) => (new Expr(/* ELambda */ 4, [arg, acc_1, span_1])), stmt.fields[1], stmt.fields[3]);
2360
2682
  let startIndex;
2361
2683
  if (telemetry == null) {
2362
2684
  startIndex = 0;
@@ -2367,31 +2689,31 @@ function inferProgramWithExternsRawAndLocals(externs, program) {
2367
2689
  }
2368
2690
  if (stmt.fields[4]) {
2369
2691
  const tv = Types_freshVar();
2370
- const patternInput = inferExpr(typeDefs, constructors, add(name_2, new Scheme(empty_2(), tv), env), exprVal);
2692
+ const patternInput = inferExpr(telemetry, typeDefs, constructors, add(name_2, new Scheme(empty_2(), tv), env), exprVal);
2371
2693
  const t1 = patternInput[1];
2372
2694
  const s1 = patternInput[0];
2373
2695
  const s2 = unify(typeDefs, applyType(s1, tv), t1, span_1);
2374
2696
  const s = compose((returnAnnotation == null) ? emptySubst : ((expectedReturn = annotationTypeFromRef(typeDefs, span_1, returnAnnotation), unify(typeDefs, functionReturnType(applyType(s2, t1)), expectedReturn, span_1))), compose(s2, s1));
2375
- applySubstToCapturedLocals(startIndex, s);
2697
+ applySubstToCapturedLocals(telemetry, startIndex, s);
2376
2698
  const env$0027 = applyEnv(s, env);
2377
2699
  const inferred = applyType(s, t1);
2378
2700
  validateMapKeyTypes(span_1, inferred);
2379
2701
  const scheme_1 = Types_generalize(env$0027, inferred);
2380
2702
  env = add(name_2, scheme_1, env$0027);
2381
- void (typed.push(new TypedStmt(1, [name_2, exprVal, inferred, true, isExported, span_1])));
2703
+ void (typed.push(new TypedStmt(/* TSLet */ 1, [name_2, exprVal, inferred, true, isExported, span_1])));
2382
2704
  }
2383
2705
  else {
2384
- const patternInput_1 = inferExpr(typeDefs, constructors, env, exprVal);
2706
+ const patternInput_1 = inferExpr(telemetry, typeDefs, constructors, env, exprVal);
2385
2707
  const t1_1 = patternInput_1[1];
2386
2708
  const s1_1 = patternInput_1[0];
2387
2709
  const s_1 = compose((returnAnnotation == null) ? emptySubst : ((expectedReturn_1 = annotationTypeFromRef(typeDefs, span_1, returnAnnotation), unify(typeDefs, functionReturnType(applyType(s1_1, t1_1)), expectedReturn_1, span_1))), s1_1);
2388
- applySubstToCapturedLocals(startIndex, s_1);
2710
+ applySubstToCapturedLocals(telemetry, startIndex, s_1);
2389
2711
  const env$0027_1 = applyEnv(s_1, env);
2390
2712
  const inferred_1 = applyType(s_1, t1_1);
2391
2713
  validateMapKeyTypes(span_1, inferred_1);
2392
2714
  const scheme_2 = Types_generalize(env$0027_1, inferred_1);
2393
2715
  env = add(name_2, scheme_2, env$0027_1);
2394
- void (typed.push(new TypedStmt(1, [name_2, exprVal, inferred_1, false, isExported, span_1])));
2716
+ void (typed.push(new TypedStmt(/* TSLet */ 1, [name_2, exprVal, inferred_1, false, isExported, span_1])));
2395
2717
  }
2396
2718
  break;
2397
2719
  }
@@ -2407,18 +2729,18 @@ function inferProgramWithExternsRawAndLocals(externs, program) {
2407
2729
  const t_2 = telemetry;
2408
2730
  startIndex_1 = t_2.LocalVariableTypes.length;
2409
2731
  }
2410
- const patternInput_2 = inferExpr(typeDefs, constructors, env, expr_1);
2732
+ const patternInput_2 = inferExpr(telemetry, typeDefs, constructors, env, expr_1);
2411
2733
  const s1_2 = patternInput_2[0];
2412
- const patternInput_3 = inferPattern(typeDefs, constructors, pattern);
2734
+ const patternInput_3 = inferPattern(telemetry, typeDefs, constructors, pattern);
2413
2735
  const s_2 = compose(unify(typeDefs, applyType(s1_2, patternInput_2[1]), patternInput_3[1], span_2), s1_2);
2414
- applySubstToCapturedLocals(startIndex_1, s_2);
2736
+ applySubstToCapturedLocals(telemetry, startIndex_1, s_2);
2415
2737
  const envBase = applyEnv(s_2, env);
2416
2738
  const typedBindings = map_1((_arg_1, ty) => applyType(s_2, ty), patternInput_3[0]);
2417
2739
  iterate_2((_arg_2, ty_1) => {
2418
2740
  validateMapKeyTypes(span_2, ty_1);
2419
2741
  }, typedBindings);
2420
2742
  env = fold_1((state_1, name_3, bindingType) => add(name_3, Types_generalize(envBase, bindingType), state_1), envBase, typedBindings);
2421
- void (typed.push(new TypedStmt(2, [pattern, expr_1, typedBindings, stmt.fields[2], span_2])));
2743
+ void (typed.push(new TypedStmt(/* TSLetPattern */ 2, [pattern, expr_1, typedBindings, stmt.fields[2], span_2])));
2422
2744
  break;
2423
2745
  }
2424
2746
  case 4: {
@@ -2434,10 +2756,10 @@ function inferProgramWithExternsRawAndLocals(externs, program) {
2434
2756
  const foldedBindings = map((tupledArg_6) => {
2435
2757
  const args_1 = tupledArg_6[1];
2436
2758
  const bindingSpan = tupledArg_6[4];
2437
- if (isEmpty(args_1)) {
2759
+ if (isEmpty_1(args_1)) {
2438
2760
  throw new TypeException(new TypeError$("\'let rec ... and ...\' requires function arguments for each binding", bindingSpan));
2439
2761
  }
2440
- return [tupledArg_6[0], tupledArg_6[2], foldBack((arg_1, acc_2) => (new Expr(4, [arg_1, acc_2, bindingSpan])), args_1, tupledArg_6[3]), bindingSpan];
2762
+ return [tupledArg_6[0], tupledArg_6[2], foldBack((arg_1, acc_2) => (new Expr(/* ELambda */ 4, [arg_1, acc_2, bindingSpan])), args_1, tupledArg_6[3]), bindingSpan];
2441
2763
  }, stmt.fields[0]);
2442
2764
  const freshByName = ofList(map((tupledArg_7) => [tupledArg_7[0], Types_freshVar()], foldedBindings), {
2443
2765
  Compare: (x_4, y_4) => (comparePrimitives(x_4, y_4) | 0),
@@ -2448,7 +2770,7 @@ function inferProgramWithExternsRawAndLocals(externs, program) {
2448
2770
  try {
2449
2771
  while (enumerator_1["System.Collections.IEnumerator.MoveNext"]()) {
2450
2772
  const forLoopVar_1 = enumerator_1["System.Collections.Generic.IEnumerator`1.get_Current"]();
2451
- const patternInput_4 = inferExpr(typeDefs, constructors, applyEnv(sRec, envRec_1), forLoopVar_1[2]);
2773
+ const patternInput_4 = inferExpr(telemetry, typeDefs, constructors, applyEnv(sRec, envRec_1), forLoopVar_1[2]);
2452
2774
  const s1_3 = patternInput_4[0];
2453
2775
  const s2_2 = unify(typeDefs, applyType(s1_3, applyType(sRec, FSharpMap__get_Item(freshByName, forLoopVar_1[0]))), patternInput_4[1], forLoopVar_1[3]);
2454
2776
  sRec = compose(s2_2, compose(s1_3, sRec));
@@ -2475,7 +2797,7 @@ function inferProgramWithExternsRawAndLocals(externs, program) {
2475
2797
  finally {
2476
2798
  disposeSafe(enumerator_2);
2477
2799
  }
2478
- applySubstToCapturedLocals(startIndex_2, sRec);
2800
+ applySubstToCapturedLocals(telemetry, startIndex_2, sRec);
2479
2801
  const envGeneralize = applyEnv(sRec, env);
2480
2802
  const schemes = map((tupledArg_8) => {
2481
2803
  const name_9 = tupledArg_8[0];
@@ -2488,7 +2810,7 @@ function inferProgramWithExternsRawAndLocals(externs, program) {
2488
2810
  return [name_10, tupledArg_9[2], applyType(sRec, FSharpMap__get_Item(freshByName, name_10)), tupledArg_9[3]];
2489
2811
  }, foldedBindings);
2490
2812
  env = fold((acc_4, tupledArg_10) => add(tupledArg_10[0], tupledArg_10[1], acc_4), envGeneralize, schemes);
2491
- void (typed.push(new TypedStmt(3, [typedBindings_1, stmt.fields[1], span_3])));
2813
+ void (typed.push(new TypedStmt(/* TSLetRecGroup */ 3, [typedBindings_1, stmt.fields[1], span_3])));
2492
2814
  break;
2493
2815
  }
2494
2816
  case 5: {
@@ -2501,54 +2823,57 @@ function inferProgramWithExternsRawAndLocals(externs, program) {
2501
2823
  const t_4 = telemetry;
2502
2824
  startIndex_3 = t_4.LocalVariableTypes.length;
2503
2825
  }
2504
- const patternInput_5 = inferExpr(typeDefs, constructors, env, expr_2);
2826
+ const patternInput_5 = inferExpr(telemetry, typeDefs, constructors, env, expr_2);
2505
2827
  const t1_3 = patternInput_5[1];
2506
2828
  const s1_4 = patternInput_5[0];
2507
- const s_3 = compose((forLoopVar[0] < (length(program) - 1)) ? unify(typeDefs, applyType(s1_4, t1_3), new Type(0, []), Ast_spanOfExpr(expr_2)) : emptySubst, s1_4);
2508
- applySubstToCapturedLocals(startIndex_3, s_3);
2829
+ const s_3 = compose((forLoopVar[0] < (length(program) - 1)) ? unify(typeDefs, applyType(s1_4, t1_3), Type.TUnit, Ast_spanOfExpr(expr_2)) : emptySubst, s1_4);
2830
+ applySubstToCapturedLocals(telemetry, startIndex_3, s_3);
2509
2831
  validateMapKeyTypes(Ast_spanOfExpr(expr_2), applyType(s_3, t1_3));
2510
2832
  env = applyEnv(s_3, env);
2511
- void (typed.push(new TypedStmt(4, [patternInput_5[2]])));
2833
+ void (typed.push(new TypedStmt(/* TSExpr */ 4, [patternInput_5[2]])));
2512
2834
  break;
2513
2835
  }
2514
2836
  default:
2515
- void (typed.push(new TypedStmt(0, [stmt.fields[0]])));
2837
+ void (typed.push(new TypedStmt(/* TSType */ 0, [stmt.fields[0]])));
2516
2838
  }
2517
2839
  }
2518
2840
  }
2519
2841
  finally {
2520
2842
  disposeSafe(enumerator);
2521
2843
  }
2522
- return [toList_1(typed), endTelemetry()];
2844
+ return [toList_1(typed), capturedLocalVariableTypes(telemetry)];
2523
2845
  }
2524
2846
  catch (matchValue_1) {
2525
- endTelemetry();
2526
2847
  throw matchValue_1;
2527
2848
  }
2528
2849
  }
2529
2850
 
2530
2851
  export function inferProgramWithExternsRaw(externs, program) {
2531
- return inferProgramWithExternsRawAndLocals(externs, program)[0];
2852
+ return inferProgramWithExternsRawAndLocals(false, externs, program)[0];
2532
2853
  }
2533
2854
 
2534
2855
  export function inferProgramWithExterns(externs, program) {
2535
- iterate_1((ext_1) => {
2536
- throw new TypeException(new TypeError$(concat("Host extern \'", ext_1.Name, "\' collides with reserved stdlib symbol"), unknownSpan));
2537
- }, toArray(tryFind_1((ext) => contains(ext.Name, builtinReservedNames), externs)));
2538
- iterate_1((name_1) => {
2539
- throw new TypeException(new TypeError$(concat("Top-level binding \'", name_1, "\' collides with reserved stdlib symbol"), unknownSpan));
2540
- }, toArray(tryFind_1((name) => contains(name, builtinReservedNames), topLevelBindingNames(program))));
2856
+ const option_1 = tryFind_1((ext) => contains(ext.Name, builtinReservedNames), externs);
2857
+ if (option_1 != null) {
2858
+ throw new TypeException(new TypeError$(concat("Host extern \'", option_1.Name, "\' collides with reserved stdlib symbol"), unknownSpan));
2859
+ }
2860
+ const option_3 = tryFind_1((name) => contains(name, builtinReservedNames), topLevelBindingNames(program));
2861
+ if (option_3 != null) {
2862
+ throw new TypeException(new TypeError$(concat("Top-level binding \'", option_3, "\' collides with reserved stdlib symbol"), unknownSpan));
2863
+ }
2541
2864
  return inferProgramWithExternsRaw(externs, program);
2542
2865
  }
2543
2866
 
2544
2867
  export function inferProgramWithExternsAndLocalVariableTypes(externs, program) {
2545
- iterate_1((ext_1) => {
2546
- throw new TypeException(new TypeError$(concat("Host extern \'", ext_1.Name, "\' collides with reserved stdlib symbol"), unknownSpan));
2547
- }, toArray(tryFind_1((ext) => contains(ext.Name, builtinReservedNames), externs)));
2548
- iterate_1((name_1) => {
2549
- throw new TypeException(new TypeError$(concat("Top-level binding \'", name_1, "\' collides with reserved stdlib symbol"), unknownSpan));
2550
- }, toArray(tryFind_1((name) => contains(name, builtinReservedNames), topLevelBindingNames(program))));
2551
- return inferProgramWithExternsRawAndLocals(externs, program);
2868
+ const option_1 = tryFind_1((ext) => contains(ext.Name, builtinReservedNames), externs);
2869
+ if (option_1 != null) {
2870
+ throw new TypeException(new TypeError$(concat("Host extern \'", option_1.Name, "\' collides with reserved stdlib symbol"), unknownSpan));
2871
+ }
2872
+ const option_3 = tryFind_1((name) => contains(name, builtinReservedNames), topLevelBindingNames(program));
2873
+ if (option_3 != null) {
2874
+ throw new TypeException(new TypeError$(concat("Top-level binding \'", option_3, "\' collides with reserved stdlib symbol"), unknownSpan));
2875
+ }
2876
+ return inferProgramWithExternsRawAndLocals(true, externs, program);
2552
2877
  }
2553
2878
 
2554
2879
  export function inferProgramWithLocalVariableTypes(program) {