@magnusopera/fscript 0.93.0 → 0.94.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.
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
|
|
2
2
|
import { Span_$reflection, Span, Position } from "./Span.js";
|
|
3
|
-
import { find, toSeq, FSharpMap__get_IsEmpty, containsKey, ofSeq as ofSeq_1, FSharpMap__Add, iterate as iterate_2, values as values_4, FSharpMap__get_Keys, keys, toList,
|
|
4
|
-
import { safeHash, curry3, arrayHash, equalArrays, compare,
|
|
5
|
-
import { PurityContractsModule_empty, Types_ftvScheme, Types_applied, Types_ftvEnv,
|
|
6
|
-
import { exactlyOne, replicate, map2, sortBy, tryFind as tryFind_1, indexed, collect as collect_2, unzip, iterate, mapIndexed, tryFindIndex, contains as
|
|
7
|
-
import {
|
|
3
|
+
import { find, toSeq, FSharpMap__get_IsEmpty, containsKey, ofSeq as ofSeq_1, FSharpMap__Add, iterate as iterate_2, values as values_4, FSharpMap__get_Keys, keys, toList, FSharpMap__get_Count, forAll, FSharpMap__ContainsKey, filter, ofList, exists as exists_1, add, fold as fold_1, FSharpMap__get_Item, remove, map, FSharpMap__TryFind, tryFind, isEmpty, empty } from "../fable_modules/fable-library-js.5.27.0/Map.js";
|
|
4
|
+
import { safeHash, curry3, arrayHash, equalArrays, compare, uncurry2, curry2, disposeSafe, getEnumerator, defaultOf, stringHash, Exception, compareArrays, equals, comparePrimitives } from "../fable_modules/fable-library-js.5.27.0/Util.js";
|
|
5
|
+
import { PurityContractsModule_empty, Types_ftvScheme, Types_applied, Types_ftvEnv, Types_generalize, Types_definitionBody, Types_freshNumeric, PurityContracts_$reflection, Scheme_$reflection, Types_ftvType, Type_$reflection, Types_freshVar, Types_$007CTypeApplication$007C_$007C, Types_typeToString, Types_expand, Scheme, Types_mapChildren, Type as Type_1 } from "./Types.js";
|
|
6
|
+
import { exactlyOne, replicate, map2, sortBy, tryFind as tryFind_1, indexed, collect as collect_2, unzip, iterate, mapIndexed, tryFindIndex, contains as contains_1, append, reverse, choose, cons, empty as empty_2, head as head_4, tail as tail_6, isEmpty as isEmpty_1, ofArrayWithTail, map as map_1, ofArray, singleton, zip, length, exists, fold } from "../fable_modules/fable-library-js.5.27.0/List.js";
|
|
7
|
+
import { recursiveOpaqueEffects, generalizeValue, InferenceEnv__AddValue_Z1D943954, factoryDelay, InferenceEnv__Add_Z72D39050, InferenceEnv__ContainsKey_Z721C83C5, InferenceEnv__TryFind_Z721C83C5, opaqueVariables, combineOpaqueEffects, OpaqueEffect, noOpaque, OpaqueEffect_$reflection, InferenceEnv, mapOpaqueEffect } from "./OpaqueInference.js";
|
|
8
|
+
import { FSharpSet__get_IsEmpty, intersect, exists as exists_3, remove as remove_1, ofList as ofList_1, difference, union, ofSeq, contains, add as add_1, toList as toList_1, empty as empty_1, FSharpSet__Add, FSharpSet__Contains } from "../fable_modules/fable-library-js.5.27.0/Set.js";
|
|
8
9
|
import { EvalException, TypeException, TypeError$ } from "./Error.js";
|
|
9
10
|
import { endsWith, split, join, concat, isNullOrWhiteSpace, printf, toText } from "../fable_modules/fable-library-js.5.27.0/String.js";
|
|
10
|
-
import { orElse, value as value_42,
|
|
11
|
+
import { orElse, flatten, value as value_42, toArray as toArray_1, defaultArg } from "../fable_modules/fable-library-js.5.27.0/Option.js";
|
|
11
12
|
import { FSharpRef, Union, Record } from "../fable_modules/fable-library-js.5.27.0/Types.js";
|
|
12
13
|
import { Attribute, Expr, Ast_spanOfPattern, TypeRef, Ast_spanOfExpr, Attribute_$reflection, BackendImport_$reflection, Pattern_$reflection, TypeDef_$reflection, Expr_$reflection } from "./Ast.js";
|
|
13
|
-
import { array_type, class_type, tuple_type, list_type, bool_type, float64_type, int64_type,
|
|
14
|
-
import { tryPick, forAll as forAll_1, tryFind as tryFind_2, foldBack, iterate as iterate_1, empty as empty_3, choose as choose_1, collect as collect_1, append as append_1, singleton as singleton_1, delay
|
|
14
|
+
import { array_type, class_type, tuple_type, list_type, bool_type, float64_type, int64_type, union_type, int32_type, string_type, option_type, record_type } from "../fable_modules/fable-library-js.5.27.0/Reflection.js";
|
|
15
|
+
import { tryPick, forAll as forAll_1, tryFind as tryFind_2, foldBack, iterate as iterate_1, exists as exists_2, empty as empty_3, choose as choose_1, collect as collect_1, append as append_1, singleton as singleton_1, delay as delay_2, fold as fold_2, toArray, filter as filter_1, map as map_2, toList as toList_2 } from "../fable_modules/fable-library-js.5.27.0/Seq.js";
|
|
15
16
|
import { last as last_2, setItem, item as item_22 } from "../fable_modules/fable-library-js.5.27.0/Array.js";
|
|
16
17
|
import { distinct } from "../fable_modules/fable-library-js.5.27.0/Seq2.js";
|
|
17
18
|
import { addToSet, getItemFromDict, addToDict, tryGetValue } from "../fable_modules/fable-library-js.5.27.0/MapUtil.js";
|
|
19
|
+
import { min } from "../fable_modules/fable-library-js.5.27.0/Double.js";
|
|
18
20
|
import { check } from "./MatchCoverage.js";
|
|
19
21
|
import { builtinReservedNames, builtinSchemes } from "./BuiltinSignatures.js";
|
|
20
22
|
import { ofExterns, typeDefinitions } from "./HostInterop.js";
|
|
@@ -134,12 +136,16 @@ function applyScheme(s, scheme) {
|
|
|
134
136
|
}
|
|
135
137
|
}
|
|
136
138
|
|
|
139
|
+
function applyOpaqueEffect(substitution, effect) {
|
|
140
|
+
return mapOpaqueEffect((t) => applyType(substitution, t), effect);
|
|
141
|
+
}
|
|
142
|
+
|
|
137
143
|
function applyEnv(s, env) {
|
|
138
144
|
if (isEmpty(s)) {
|
|
139
145
|
return env;
|
|
140
146
|
}
|
|
141
147
|
else {
|
|
142
|
-
return map((_arg,
|
|
148
|
+
return new InferenceEnv(map((_arg, scheme) => applyScheme(s, scheme), env.Schemes), map((name, effect) => applyOpaqueEffect(fold((state, variable) => remove(variable, state), s, FSharpMap__get_Item(env.Schemes, name).fields[0]), effect), env.OpaqueEffects), env.Frames);
|
|
143
149
|
}
|
|
144
150
|
}
|
|
145
151
|
|
|
@@ -1443,6 +1449,72 @@ export function TypedExpr_$reflection() {
|
|
|
1443
1449
|
return record_type("FScript.Language.TypeInfer.TypedExpr", [], TypedExpr, () => [["Expr", Expr_$reflection()], ["Type", Type_$reflection()], ["Span", Span_$reflection()]]);
|
|
1444
1450
|
}
|
|
1445
1451
|
|
|
1452
|
+
class InferredExpr extends Record {
|
|
1453
|
+
constructor(Typed, Opaque) {
|
|
1454
|
+
super();
|
|
1455
|
+
this.Typed = Typed;
|
|
1456
|
+
this.Opaque = Opaque;
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
function InferredExpr_$reflection() {
|
|
1461
|
+
return record_type("FScript.Language.TypeInfer.InferredExpr", [], InferredExpr, () => [["Typed", TypedExpr_$reflection()], ["Opaque", option_type(OpaqueEffect_$reflection())]]);
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
function withOpaqueEffect(effect, value) {
|
|
1465
|
+
return new InferredExpr(value.Typed, effect);
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
function effectOf(value) {
|
|
1469
|
+
return defaultArg(value.Opaque, noOpaque);
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
function valueSignature(env, name, typ) {
|
|
1473
|
+
const effect = defaultArg(tryFind(name, env.OpaqueEffects), noOpaque);
|
|
1474
|
+
if (equals(effect, noOpaque)) {
|
|
1475
|
+
return [typ, (typ_1) => [typ_1, noOpaque]];
|
|
1476
|
+
}
|
|
1477
|
+
else {
|
|
1478
|
+
const depths = map_1((tuple) => (tuple[0] | 0), toList(effect.Latent));
|
|
1479
|
+
const encode = (variables) => (new Type_1(/* TTuple */ 7, [map_1((Item) => (new Type_1(/* TVar */ 17, [Item])), toList_1(variables))]));
|
|
1480
|
+
return [new Type_1(/* TTuple */ 7, [ofArrayWithTail([typ, encode(effect.Live)], map_1((depth) => encode(FSharpMap__get_Item(effect.Latent, depth)), depths))]), (_arg) => {
|
|
1481
|
+
let matchResult, latent, live, typ_2;
|
|
1482
|
+
if (_arg.tag === 7) {
|
|
1483
|
+
if (!isEmpty_1(_arg.fields[0])) {
|
|
1484
|
+
if (!isEmpty_1(tail_6(_arg.fields[0]))) {
|
|
1485
|
+
matchResult = 0;
|
|
1486
|
+
latent = tail_6(tail_6(_arg.fields[0]));
|
|
1487
|
+
live = head_4(tail_6(_arg.fields[0]));
|
|
1488
|
+
typ_2 = head_4(_arg.fields[0]);
|
|
1489
|
+
}
|
|
1490
|
+
else {
|
|
1491
|
+
matchResult = 1;
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
else {
|
|
1495
|
+
matchResult = 1;
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
else {
|
|
1499
|
+
matchResult = 1;
|
|
1500
|
+
}
|
|
1501
|
+
switch (matchResult) {
|
|
1502
|
+
case 0:
|
|
1503
|
+
return [typ_2, new OpaqueEffect(Types_ftvType(live), ofList(map_1((tupledArg) => [tupledArg[0], Types_ftvType(tupledArg[1])], zip(depths, latent)), {
|
|
1504
|
+
Compare: (x, y) => (comparePrimitives(x, y) | 0),
|
|
1505
|
+
}), effect.FactoryDelay)];
|
|
1506
|
+
default:
|
|
1507
|
+
throw new Exception("Invalid opaque inference metadata");
|
|
1508
|
+
}
|
|
1509
|
+
}];
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
function instantiateValue(env, name, _arg) {
|
|
1514
|
+
const patternInput = valueSignature(env, name, _arg.fields[1]);
|
|
1515
|
+
return patternInput[1](instantiate(new Scheme(_arg.fields[0], patternInput[0])));
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1446
1518
|
export class LocalVariableTypeInfo extends Record {
|
|
1447
1519
|
constructor(Name, Span, Type) {
|
|
1448
1520
|
super();
|
|
@@ -1894,7 +1966,7 @@ function capturedLocalVariableTypes(telemetry) {
|
|
|
1894
1966
|
return empty_2();
|
|
1895
1967
|
}
|
|
1896
1968
|
else {
|
|
1897
|
-
return
|
|
1969
|
+
return toList_2(map_2((item) => (new LocalVariableTypeInfo(item.Name, item.Span, item.Type)), telemetry.LocalVariableTypes));
|
|
1898
1970
|
}
|
|
1899
1971
|
}
|
|
1900
1972
|
|
|
@@ -1934,7 +2006,7 @@ function recordLocalVariableUse(telemetry, name, span, varType) {
|
|
|
1934
2006
|
let matchValue;
|
|
1935
2007
|
if (telemetry != null) {
|
|
1936
2008
|
const t = telemetry;
|
|
1937
|
-
if (
|
|
2009
|
+
if (contains(name, (matchValue = t.ScopeStack, isEmpty_1(matchValue) ? empty_1({
|
|
1938
2010
|
Compare: (x, y) => (comparePrimitives(x, y) | 0),
|
|
1939
2011
|
}) : head_4(matchValue)))) {
|
|
1940
2012
|
void (t.LocalVariableTypes.push(new LocalVariableTypeCapture(name, span, varType)));
|
|
@@ -2004,7 +2076,7 @@ function asTyped(telemetry, expr, t) {
|
|
|
2004
2076
|
const capture = telemetry;
|
|
2005
2077
|
void (capture.ExpressionTypes.push(new ResolvedExpressionType(expr, t, span)));
|
|
2006
2078
|
}
|
|
2007
|
-
return new TypedExpr(expr, t, span);
|
|
2079
|
+
return new InferredExpr(new TypedExpr(expr, t, span), undefined);
|
|
2008
2080
|
}
|
|
2009
2081
|
|
|
2010
2082
|
function builtinType(name) {
|
|
@@ -2086,13 +2158,13 @@ function resolveNamedRecordByFieldSet(typeDefs, fields, span) {
|
|
|
2086
2158
|
}
|
|
2087
2159
|
}, toList(typeDefs));
|
|
2088
2160
|
if (isEmpty_1(matches)) {
|
|
2089
|
-
throw new TypeException(new TypeError$(concat("No declared record type matches fields ", concat("{ ", join("; ",
|
|
2161
|
+
throw new TypeException(new TypeError$(concat("No declared record type matches fields ", concat("{ ", join("; ", toList_1(fields)), " }")), span));
|
|
2090
2162
|
}
|
|
2091
2163
|
else if (isEmpty_1(tail_6(matches))) {
|
|
2092
2164
|
return head_4(matches);
|
|
2093
2165
|
}
|
|
2094
2166
|
else {
|
|
2095
|
-
throw new TypeException(new TypeError$(concat("Ambiguous declared record type for fields ", concat("{ ", join("; ",
|
|
2167
|
+
throw new TypeException(new TypeError$(concat("Ambiguous declared record type for fields ", concat("{ ", join("; ", toList_1(fields)), " }"), ": ", join(", ", matches)), span));
|
|
2096
2168
|
}
|
|
2097
2169
|
}
|
|
2098
2170
|
|
|
@@ -2104,7 +2176,7 @@ function resolveReferencedTypeName(knownNames, name, span) {
|
|
|
2104
2176
|
}
|
|
2105
2177
|
else if (name.indexOf(".") >= 0) {
|
|
2106
2178
|
const shortName = last_2(split(name, ["."], undefined, 0));
|
|
2107
|
-
const matches =
|
|
2179
|
+
const matches = toList_2(distinct(filter_1((candidate) => {
|
|
2108
2180
|
if (candidate === shortName) {
|
|
2109
2181
|
return true;
|
|
2110
2182
|
}
|
|
@@ -2319,7 +2391,7 @@ function generalizeBinding(outerScope, env, substitution, explicitParameters, in
|
|
|
2319
2391
|
const matchValue = applyType(substitution, tupledArg_1[1]);
|
|
2320
2392
|
let matchResult, id_1;
|
|
2321
2393
|
if (matchValue.tag === 17) {
|
|
2322
|
-
if ((id = (matchValue.fields[0] | 0), !(
|
|
2394
|
+
if ((id = (matchValue.fields[0] | 0), !(contains(id, captured) ? true : contains(id, used)))) {
|
|
2323
2395
|
matchResult = 0;
|
|
2324
2396
|
id_1 = matchValue.fields[0];
|
|
2325
2397
|
}
|
|
@@ -2339,171 +2411,12 @@ function generalizeBinding(outerScope, env, substitution, explicitParameters, in
|
|
|
2339
2411
|
}, [empty_2(), empty_1({
|
|
2340
2412
|
Compare: (x, y) => (comparePrimitives(x, y) | 0),
|
|
2341
2413
|
})], explicitParameters)[0]);
|
|
2342
|
-
return new Scheme(append(ordered,
|
|
2414
|
+
return new Scheme(append(ordered, toList_1(difference(Types_ftvType(inferred), union(captured, ofList_1(ordered, {
|
|
2343
2415
|
Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
|
|
2344
2416
|
}))))), inferred);
|
|
2345
2417
|
}
|
|
2346
2418
|
}
|
|
2347
2419
|
|
|
2348
|
-
function generalizeValueBinding(typeDefs, expression, generalize, inferred) {
|
|
2349
|
-
const isNonExpansive = (_arg_mut) => {
|
|
2350
|
-
isNonExpansive:
|
|
2351
|
-
while (true) {
|
|
2352
|
-
const _arg = _arg_mut;
|
|
2353
|
-
switch (_arg.tag) {
|
|
2354
|
-
case 4: {
|
|
2355
|
-
_arg_mut = _arg.fields[0];
|
|
2356
|
-
continue isNonExpansive;
|
|
2357
|
-
}
|
|
2358
|
-
case 5:
|
|
2359
|
-
case 2:
|
|
2360
|
-
return true;
|
|
2361
|
-
default:
|
|
2362
|
-
return false;
|
|
2363
|
-
}
|
|
2364
|
-
break;
|
|
2365
|
-
}
|
|
2366
|
-
};
|
|
2367
|
-
const containsGenericHostValue = (visited, typ) => {
|
|
2368
|
-
const contains = curry2(containsGenericHostValue)(visited);
|
|
2369
|
-
const expand = (name) => {
|
|
2370
|
-
if (!contains_1(name, visited)) {
|
|
2371
|
-
return containsGenericHostValue(add_1(name, visited), Types_expand(typeDefs, typ));
|
|
2372
|
-
}
|
|
2373
|
-
else {
|
|
2374
|
-
return false;
|
|
2375
|
-
}
|
|
2376
|
-
};
|
|
2377
|
-
let matchResult, item, a, b, fields;
|
|
2378
|
-
switch (typ.tag) {
|
|
2379
|
-
case 13: {
|
|
2380
|
-
matchResult = 0;
|
|
2381
|
-
break;
|
|
2382
|
-
}
|
|
2383
|
-
case 12: {
|
|
2384
|
-
matchResult = 1;
|
|
2385
|
-
break;
|
|
2386
|
-
}
|
|
2387
|
-
case 15: {
|
|
2388
|
-
matchResult = 2;
|
|
2389
|
-
break;
|
|
2390
|
-
}
|
|
2391
|
-
case 5: {
|
|
2392
|
-
matchResult = 3;
|
|
2393
|
-
item = typ.fields[0];
|
|
2394
|
-
break;
|
|
2395
|
-
}
|
|
2396
|
-
case 10: {
|
|
2397
|
-
matchResult = 3;
|
|
2398
|
-
item = typ.fields[0];
|
|
2399
|
-
break;
|
|
2400
|
-
}
|
|
2401
|
-
case 6: {
|
|
2402
|
-
matchResult = 3;
|
|
2403
|
-
item = typ.fields[0];
|
|
2404
|
-
break;
|
|
2405
|
-
}
|
|
2406
|
-
case 11: {
|
|
2407
|
-
matchResult = 4;
|
|
2408
|
-
a = typ.fields[0];
|
|
2409
|
-
b = typ.fields[1];
|
|
2410
|
-
break;
|
|
2411
|
-
}
|
|
2412
|
-
case 9: {
|
|
2413
|
-
matchResult = 4;
|
|
2414
|
-
a = typ.fields[0];
|
|
2415
|
-
b = typ.fields[1];
|
|
2416
|
-
break;
|
|
2417
|
-
}
|
|
2418
|
-
case 7: {
|
|
2419
|
-
matchResult = 5;
|
|
2420
|
-
break;
|
|
2421
|
-
}
|
|
2422
|
-
case 8: {
|
|
2423
|
-
matchResult = 6;
|
|
2424
|
-
fields = typ.fields[0];
|
|
2425
|
-
break;
|
|
2426
|
-
}
|
|
2427
|
-
case 20: {
|
|
2428
|
-
matchResult = 6;
|
|
2429
|
-
fields = typ.fields[1];
|
|
2430
|
-
break;
|
|
2431
|
-
}
|
|
2432
|
-
case 19: {
|
|
2433
|
-
matchResult = 6;
|
|
2434
|
-
fields = typ.fields[1];
|
|
2435
|
-
break;
|
|
2436
|
-
}
|
|
2437
|
-
default:
|
|
2438
|
-
matchResult = 7;
|
|
2439
|
-
}
|
|
2440
|
-
switch (matchResult) {
|
|
2441
|
-
case 0: {
|
|
2442
|
-
const name_1 = typ.fields[0];
|
|
2443
|
-
const matchValue = tryFind(name_1, typeDefs);
|
|
2444
|
-
let matchResult_1;
|
|
2445
|
-
if (matchValue != null) {
|
|
2446
|
-
if (matchValue.tag === 14) {
|
|
2447
|
-
if (matchValue.fields[1].tag === 19) {
|
|
2448
|
-
matchResult_1 = 0;
|
|
2449
|
-
}
|
|
2450
|
-
else {
|
|
2451
|
-
matchResult_1 = 1;
|
|
2452
|
-
}
|
|
2453
|
-
}
|
|
2454
|
-
else {
|
|
2455
|
-
matchResult_1 = 1;
|
|
2456
|
-
}
|
|
2457
|
-
}
|
|
2458
|
-
else {
|
|
2459
|
-
matchResult_1 = 1;
|
|
2460
|
-
}
|
|
2461
|
-
switch (matchResult_1) {
|
|
2462
|
-
case 0:
|
|
2463
|
-
return true;
|
|
2464
|
-
default:
|
|
2465
|
-
if (exists(contains, typ.fields[1])) {
|
|
2466
|
-
return true;
|
|
2467
|
-
}
|
|
2468
|
-
else {
|
|
2469
|
-
return expand(name_1);
|
|
2470
|
-
}
|
|
2471
|
-
}
|
|
2472
|
-
}
|
|
2473
|
-
case 1:
|
|
2474
|
-
return expand(typ.fields[0]);
|
|
2475
|
-
case 2:
|
|
2476
|
-
return exists_1((_arg_1, payload) => exists_2(contains, toArray_1(payload)), typ.fields[1]);
|
|
2477
|
-
case 3:
|
|
2478
|
-
return contains(item);
|
|
2479
|
-
case 4:
|
|
2480
|
-
if (contains(a)) {
|
|
2481
|
-
return true;
|
|
2482
|
-
}
|
|
2483
|
-
else {
|
|
2484
|
-
return contains(b);
|
|
2485
|
-
}
|
|
2486
|
-
case 5:
|
|
2487
|
-
return exists(contains, typ.fields[0]);
|
|
2488
|
-
case 6:
|
|
2489
|
-
return exists_1(uncurry2((_arg_2) => contains), fields);
|
|
2490
|
-
default:
|
|
2491
|
-
return false;
|
|
2492
|
-
}
|
|
2493
|
-
};
|
|
2494
|
-
if (inferred.tag === 11) {
|
|
2495
|
-
return generalize(inferred);
|
|
2496
|
-
}
|
|
2497
|
-
else if ((!isNonExpansive(expression) && !isEmpty_2(Types_ftvType(inferred))) && containsGenericHostValue(empty_1({
|
|
2498
|
-
Compare: (x, y) => (comparePrimitives(x, y) | 0),
|
|
2499
|
-
}), inferred)) {
|
|
2500
|
-
return new Scheme(empty_2(), inferred);
|
|
2501
|
-
}
|
|
2502
|
-
else {
|
|
2503
|
-
return generalize(inferred);
|
|
2504
|
-
}
|
|
2505
|
-
}
|
|
2506
|
-
|
|
2507
2420
|
function functionReturnType(arity_mut, typ_mut) {
|
|
2508
2421
|
functionReturnType:
|
|
2509
2422
|
while (true) {
|
|
@@ -2575,7 +2488,7 @@ function typeFromRef(hostTypes, variables, decls, stack, tref) {
|
|
|
2575
2488
|
}
|
|
2576
2489
|
else if ((def = matchValue_1, !isEmpty_1(def.TypeParameters) && (length(def.TypeParameters) === length(arguments$)))) {
|
|
2577
2490
|
const def_1 = matchValue_1;
|
|
2578
|
-
if (
|
|
2491
|
+
if (contains_1(resolved, stack, {
|
|
2579
2492
|
Equals: (x, y) => (x === y),
|
|
2580
2493
|
GetHashCode: (x) => (stringHash(x) | 0),
|
|
2581
2494
|
})) {
|
|
@@ -2715,7 +2628,7 @@ export function scriptTypeDefinitions(hostTypes, declarations) {
|
|
|
2715
2628
|
}
|
|
2716
2629
|
}, declarations);
|
|
2717
2630
|
if (exists_1((_arg_1, definition_1) => !isEmpty_1(definition_1.TypeParameters), declarations)) {
|
|
2718
|
-
const referenced = (typ_1) =>
|
|
2631
|
+
const referenced = (typ_1) => delay_2(() => {
|
|
2719
2632
|
let matchResult, item, left, right;
|
|
2720
2633
|
switch (typ_1.tag) {
|
|
2721
2634
|
case 12: {
|
|
@@ -2772,7 +2685,7 @@ export function scriptTypeDefinitions(hostTypes, declarations) {
|
|
|
2772
2685
|
case 0:
|
|
2773
2686
|
return singleton_1(typ_1.fields[0]);
|
|
2774
2687
|
case 1:
|
|
2775
|
-
return append_1(singleton_1(typ_1.fields[0]),
|
|
2688
|
+
return append_1(singleton_1(typ_1.fields[0]), delay_2(() => collect_1(referenced, typ_1.fields[1])));
|
|
2776
2689
|
case 2:
|
|
2777
2690
|
return collect_1(referenced, typ_1.fields[0]);
|
|
2778
2691
|
case 3:
|
|
@@ -2782,7 +2695,7 @@ export function scriptTypeDefinitions(hostTypes, declarations) {
|
|
|
2782
2695
|
case 5:
|
|
2783
2696
|
return referenced(item);
|
|
2784
2697
|
case 6:
|
|
2785
|
-
return append_1(referenced(left),
|
|
2698
|
+
return append_1(referenced(left), delay_2(() => referenced(right)));
|
|
2786
2699
|
default: {
|
|
2787
2700
|
return empty_3();
|
|
2788
2701
|
}
|
|
@@ -2961,7 +2874,7 @@ function constrainMapKeyTypes(typeDefs, span, t) {
|
|
|
2961
2874
|
case 5: {
|
|
2962
2875
|
const name = matchValue.fields[0];
|
|
2963
2876
|
iterate(curry2(loop)(visited), matchValue.fields[1]);
|
|
2964
|
-
if (!
|
|
2877
|
+
if (!contains(name, visited)) {
|
|
2965
2878
|
const visited_1 = add_1(name, visited);
|
|
2966
2879
|
const matchValue_1 = Types_expand(typeDefs, matchValue);
|
|
2967
2880
|
switch (matchValue_1.tag) {
|
|
@@ -3276,6 +3189,7 @@ function validateMapKeyTypes(typeDefs, span, t) {
|
|
|
3276
3189
|
}
|
|
3277
3190
|
|
|
3278
3191
|
function inferExpr(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
3192
|
+
let matchValue_1, combined_2, matchValue_2, matchValue_3, left, right;
|
|
3279
3193
|
let expressionStart;
|
|
3280
3194
|
if (telemetry == null) {
|
|
3281
3195
|
expressionStart = 0;
|
|
@@ -3284,14 +3198,52 @@ function inferExpr(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
|
3284
3198
|
const t = telemetry;
|
|
3285
3199
|
expressionStart = t.ExpressionTypes.length;
|
|
3286
3200
|
}
|
|
3287
|
-
const
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3201
|
+
const children = [];
|
|
3202
|
+
void (env.Frames.push(children));
|
|
3203
|
+
let result;
|
|
3204
|
+
try {
|
|
3205
|
+
const patternInput = inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr);
|
|
3206
|
+
const subst = patternInput[0];
|
|
3207
|
+
const inferred = patternInput[1];
|
|
3208
|
+
const combined = compose(constrainMapKeyTypes(typeDefs, Ast_spanOfExpr(expr), applyType(subst, inferred)), subst);
|
|
3209
|
+
const resolved = applyType(combined, inferred);
|
|
3210
|
+
const call = (fn, argument) => {
|
|
3211
|
+
let matchValue, source, delay, option_2, delay_1;
|
|
3212
|
+
const promoted = defaultArg(tryFind(1, fn.Latent), empty_1({
|
|
3213
|
+
Compare: (x, y) => (comparePrimitives(x, y) | 0),
|
|
3214
|
+
}));
|
|
3215
|
+
const combined_1 = combineOpaqueEffects([(matchValue = fn.FactoryDelay, (matchValue == null) ? (new OpaqueEffect(union(argument.Live, (source = values_4(argument.Latent), fold_2(union, empty_1({
|
|
3216
|
+
Compare: (x_2, y_2) => (comparePrimitives(x_2, y_2) | 0),
|
|
3217
|
+
}), source))), empty({
|
|
3218
|
+
Compare: (x_3, y_3) => (comparePrimitives(x_3, y_3) | 0),
|
|
3219
|
+
}), argument.FactoryDelay)) : ((delay = (matchValue | 0), new OpaqueEffect(argument.Live, ofList(map_1((tupledArg) => [tupledArg[0] + delay, tupledArg[1]], toList(argument.Latent)), {
|
|
3220
|
+
Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
|
|
3221
|
+
}), argument.FactoryDelay)))), new OpaqueEffect(union(fn.Live, promoted), ofList(choose((tupledArg_1) => {
|
|
3222
|
+
const depth_1 = tupledArg_1[0] | 0;
|
|
3223
|
+
if (depth_1 > 1) {
|
|
3224
|
+
return [depth_1 - 1, tupledArg_1[1]];
|
|
3225
|
+
}
|
|
3226
|
+
else {
|
|
3227
|
+
return undefined;
|
|
3228
|
+
}
|
|
3229
|
+
}, toList(fn.Latent)), {
|
|
3230
|
+
Compare: (x_4, y_4) => (comparePrimitives(x_4, y_4) | 0),
|
|
3231
|
+
}), noOpaque.FactoryDelay)]);
|
|
3232
|
+
return new OpaqueEffect(combined_1.Live, combined_1.Latent, (option_2 = fn.FactoryDelay, (option_2 != null) ? ((delay_1 = (option_2 | 0), (delay_1 > 0) ? (delay_1 - 1) : undefined)) : undefined));
|
|
3233
|
+
};
|
|
3234
|
+
const effect_2 = applyOpaqueEffect(combined, (matchValue_1 = patternInput[2].Opaque, (matchValue_1 == null) ? ((expr.tag === 6) ? ((children.length === 2) ? call(item_22(0, children), item_22(1, children)) : combineOpaqueEffects(children)) : ((expr.tag === 26) ? ((expr.fields[0] === "|>") ? ((children.length === 2) ? call(item_22(1, children), item_22(0, children)) : combineOpaqueEffects(children)) : combineOpaqueEffects(children)) : ((expr.tag === 7) ? ((children.length === 3) ? ((combined_2 = combineOpaqueEffects(children), (matchValue_2 = item_22(1, children).FactoryDelay, (matchValue_3 = item_22(2, children).FactoryDelay, (matchValue_2 != null) ? ((matchValue_3 != null) ? ((left = (matchValue_2 | 0), (right = (matchValue_3 | 0), new OpaqueEffect(combined_2.Live, combined_2.Latent, min(left, right))))) : combined_2) : combined_2)))) : combineOpaqueEffects(children)) : combineOpaqueEffects(children)))) : matchValue_1));
|
|
3235
|
+
const effect_3 = new OpaqueEffect(union(effect_2.Live, opaqueVariables(typeDefs, resolved)), effect_2.Latent, effect_2.FactoryDelay);
|
|
3236
|
+
applyAnnotationScope(scope, combined);
|
|
3237
|
+
applySubstToCapturedExpressions(telemetry, expressionStart, combined);
|
|
3238
|
+
result = [combined, resolved, new InferredExpr(new TypedExpr(expr, resolved, Ast_spanOfExpr(expr)), effect_3)];
|
|
3239
|
+
}
|
|
3240
|
+
finally {
|
|
3241
|
+
env.Frames.splice(env.Frames.length - 1, 1);
|
|
3242
|
+
}
|
|
3243
|
+
if (env.Frames.length > 0) {
|
|
3244
|
+
void (item_22(env.Frames.length - 1, env.Frames).push(effectOf(result[2])));
|
|
3245
|
+
}
|
|
3246
|
+
return result;
|
|
3295
3247
|
}
|
|
3296
3248
|
|
|
3297
3249
|
function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
@@ -3305,14 +3257,15 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
|
3305
3257
|
case 2: {
|
|
3306
3258
|
const span = expr.fields[1];
|
|
3307
3259
|
const name = expr.fields[0];
|
|
3308
|
-
const matchValue =
|
|
3260
|
+
const matchValue = InferenceEnv__TryFind_Z721C83C5(env, name);
|
|
3309
3261
|
if (matchValue == null) {
|
|
3310
3262
|
throw new TypeException(new TypeError$(toText(printf("Unbound variable \'%s\'"))(name), span));
|
|
3311
3263
|
}
|
|
3312
3264
|
else {
|
|
3313
|
-
const
|
|
3265
|
+
const patternInput = instantiateValue(env, name, matchValue);
|
|
3266
|
+
const t_1 = patternInput[0];
|
|
3314
3267
|
recordLocalVariableUse(telemetry, name, span, t_1);
|
|
3315
|
-
return [emptySubst, t_1, asTyped(telemetry, expr, t_1)];
|
|
3268
|
+
return [emptySubst, t_1, withOpaqueEffect(patternInput[1], asTyped(telemetry, expr, t_1))];
|
|
3316
3269
|
}
|
|
3317
3270
|
}
|
|
3318
3271
|
case 3: {
|
|
@@ -3338,17 +3291,20 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
|
3338
3291
|
};
|
|
3339
3292
|
let matchValue_1;
|
|
3340
3293
|
const option_3 = qualified(target);
|
|
3341
|
-
matchValue_1 = ((option_3 != null) ?
|
|
3294
|
+
matchValue_1 = ((option_3 != null) ? InferenceEnv__TryFind_Z721C83C5(env, option_3) : undefined);
|
|
3342
3295
|
if (matchValue_1 == null) {
|
|
3343
3296
|
throw new TypeException(new TypeError$("Explicit type arguments require a named function or constructor", span_1));
|
|
3344
3297
|
}
|
|
3345
3298
|
else if ((matchValue_1.fields[1], (parameters = matchValue_1.fields[0], !isEmpty_1(parameters) && (length(parameters) === length(arguments$))))) {
|
|
3346
3299
|
const parameters_1 = matchValue_1.fields[0];
|
|
3347
3300
|
const signature_1 = matchValue_1.fields[1];
|
|
3348
|
-
const
|
|
3349
|
-
const
|
|
3301
|
+
const values = map_1((tref) => scopedAnnotation(scope, typeDefs, span_1, tref), arguments$);
|
|
3302
|
+
const patternInput_1 = valueSignature(env, value_42(qualified(target)), signature_1);
|
|
3303
|
+
const patternInput_2 = instantiateExplicit(typeDefs, span_1, parameters_1, values, patternInput_1[0]);
|
|
3304
|
+
const patternInput_3 = patternInput_1[1](patternInput_2[1]);
|
|
3305
|
+
const t_2 = patternInput_3[0];
|
|
3350
3306
|
asTyped(telemetry, target, t_2);
|
|
3351
|
-
return [
|
|
3307
|
+
return [patternInput_2[0], t_2, withOpaqueEffect(patternInput_3[1], asTyped(telemetry, expr, t_2))];
|
|
3352
3308
|
}
|
|
3353
3309
|
else {
|
|
3354
3310
|
const parameters_2 = matchValue_1.fields[0];
|
|
@@ -3356,31 +3312,31 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
|
3356
3312
|
}
|
|
3357
3313
|
}
|
|
3358
3314
|
case 4: {
|
|
3359
|
-
const
|
|
3360
|
-
const t_3 =
|
|
3361
|
-
return [
|
|
3315
|
+
const patternInput_4 = inferExpr(telemetry, typeDefs, constructors, scope, env, expr.fields[0]);
|
|
3316
|
+
const t_3 = patternInput_4[1];
|
|
3317
|
+
return [patternInput_4[0], t_3, asTyped(telemetry, expr, t_3)];
|
|
3362
3318
|
}
|
|
3363
3319
|
case 29: {
|
|
3364
3320
|
const span_2 = expr.fields[1];
|
|
3365
|
-
const
|
|
3366
|
-
const matchValue_2 = FSharpMap__TryFind(typeDefs,
|
|
3321
|
+
const name_4 = expr.fields[0];
|
|
3322
|
+
const matchValue_2 = FSharpMap__TryFind(typeDefs, name_4);
|
|
3367
3323
|
if (matchValue_2 == null) {
|
|
3368
|
-
throw new TypeException(new TypeError$(toText(printf("Unknown type \'%s\'"))(
|
|
3324
|
+
throw new TypeException(new TypeError$(toText(printf("Unknown type \'%s\'"))(name_4), span_2));
|
|
3369
3325
|
}
|
|
3370
3326
|
else if (matchValue_2.tag === 14) {
|
|
3371
|
-
throw new TypeException(new TypeError$(concat("Type \'",
|
|
3327
|
+
throw new TypeException(new TypeError$(concat("Type \'", name_4, "\' requires type arguments"), span_2));
|
|
3372
3328
|
}
|
|
3373
3329
|
else {
|
|
3374
3330
|
return [emptySubst, Type_1.TTypeToken, asTyped(telemetry, expr, Type_1.TTypeToken)];
|
|
3375
3331
|
}
|
|
3376
3332
|
}
|
|
3377
3333
|
case 30: {
|
|
3378
|
-
const
|
|
3379
|
-
if (
|
|
3334
|
+
const name_5 = expr.fields[0];
|
|
3335
|
+
if (InferenceEnv__ContainsKey_Z721C83C5(env, name_5)) {
|
|
3380
3336
|
return [emptySubst, Type_1.TString, asTyped(telemetry, expr, Type_1.TString)];
|
|
3381
3337
|
}
|
|
3382
3338
|
else {
|
|
3383
|
-
throw new TypeException(new TypeError$(toText(printf("Unbound variable \'%s\'"))(
|
|
3339
|
+
throw new TypeException(new TypeError$(toText(printf("Unbound variable \'%s\'"))(name_5), expr.fields[1]));
|
|
3384
3340
|
}
|
|
3385
3341
|
}
|
|
3386
3342
|
case 31: {
|
|
@@ -3390,8 +3346,8 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
|
3390
3346
|
while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
|
|
3391
3347
|
const part = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
3392
3348
|
if (part.tag === 1) {
|
|
3393
|
-
const
|
|
3394
|
-
sAcc = compose(
|
|
3349
|
+
const patternInput_5 = inferExpr(telemetry, typeDefs, constructors, scope, applyEnv(sAcc, env), part.fields[0]);
|
|
3350
|
+
sAcc = compose(patternInput_5[0], sAcc);
|
|
3395
3351
|
}
|
|
3396
3352
|
}
|
|
3397
3353
|
}
|
|
@@ -3402,138 +3358,167 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
|
3402
3358
|
}
|
|
3403
3359
|
case 5: {
|
|
3404
3360
|
const param = expr.fields[0];
|
|
3361
|
+
const body = expr.fields[1];
|
|
3405
3362
|
let tv;
|
|
3406
3363
|
const matchValue_3 = param.Annotation;
|
|
3407
3364
|
tv = ((matchValue_3 == null) ? Types_freshVar() : scopedAnnotation(scope, typeDefs, param.Span, matchValue_3));
|
|
3408
3365
|
recordLocalVariableDeclaration(telemetry, param.Name, param.Span, tv);
|
|
3409
|
-
const env$0027 =
|
|
3410
|
-
const
|
|
3411
|
-
const s1_1 =
|
|
3412
|
-
const tFun = new Type_1(/* TFun */ 11, [applyType(s1_1, tv),
|
|
3413
|
-
|
|
3366
|
+
const env$0027 = InferenceEnv__Add_Z72D39050(env, param.Name, new Scheme(empty_2(), tv));
|
|
3367
|
+
const patternInput_6 = withLocalBindings(telemetry, singleton(param.Name), () => inferExpr(telemetry, typeDefs, constructors, scope, env$0027, body));
|
|
3368
|
+
const s1_1 = patternInput_6[0];
|
|
3369
|
+
const tFun = new Type_1(/* TFun */ 11, [applyType(s1_1, tv), patternInput_6[1]]);
|
|
3370
|
+
const bodyEffect = applyOpaqueEffect(s1_1, effectOf(patternInput_6[2]));
|
|
3371
|
+
const capturedEnv = applyEnv(s1_1, env);
|
|
3372
|
+
let captured;
|
|
3373
|
+
const source = delay_2(() => append_1(collect_1((matchValue_4) => singleton_1(opaqueVariables(typeDefs, matchValue_4[1].fields[1])), capturedEnv.Schemes), delay_2(() => collect_1((matchValue_5) => singleton_1(matchValue_5[1].Live), capturedEnv.OpaqueEffects))));
|
|
3374
|
+
captured = fold_2(union, empty_1({
|
|
3375
|
+
Compare: (x, y) => (comparePrimitives(x, y) | 0),
|
|
3376
|
+
}), source);
|
|
3377
|
+
const live = intersect(captured, bodyEffect.Live);
|
|
3378
|
+
const created = difference(bodyEffect.Live, captured);
|
|
3379
|
+
const latent = ofList(map_1((tupledArg) => [tupledArg[0] + 1, tupledArg[1]], toList(bodyEffect.Latent)), {
|
|
3380
|
+
Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
|
|
3381
|
+
});
|
|
3382
|
+
const knownForwarders = remove(param.Name, ofList(choose((tupledArg_1) => {
|
|
3383
|
+
const option_6 = tupledArg_1[1].FactoryDelay;
|
|
3384
|
+
if (option_6 != null) {
|
|
3385
|
+
return [tupledArg_1[0], option_6];
|
|
3386
|
+
}
|
|
3387
|
+
else {
|
|
3388
|
+
return undefined;
|
|
3389
|
+
}
|
|
3390
|
+
}, toList(capturedEnv.OpaqueEffects)), {
|
|
3391
|
+
Compare: (x_2, y_2) => (comparePrimitives(x_2, y_2) | 0),
|
|
3392
|
+
}));
|
|
3393
|
+
return [s1_1, tFun, withOpaqueEffect(new OpaqueEffect(live, FSharpSet__get_IsEmpty(created) ? latent : add(1, created, latent), factoryDelay(knownForwarders, body)), asTyped(telemetry, expr, tFun))];
|
|
3414
3394
|
}
|
|
3415
3395
|
case 6: {
|
|
3416
3396
|
const span_5 = expr.fields[2];
|
|
3417
|
-
const
|
|
3418
|
-
const s1_2 =
|
|
3419
|
-
const
|
|
3420
|
-
const t2 =
|
|
3421
|
-
const s2 =
|
|
3397
|
+
const patternInput_7 = inferExpr(telemetry, typeDefs, constructors, scope, env, expr.fields[0]);
|
|
3398
|
+
const s1_2 = patternInput_7[0];
|
|
3399
|
+
const patternInput_8 = inferExpr(telemetry, typeDefs, constructors, scope, applyEnv(s1_2, env), expr.fields[1]);
|
|
3400
|
+
const t2 = patternInput_8[1];
|
|
3401
|
+
const s2 = patternInput_8[0];
|
|
3422
3402
|
const tv_1 = Types_freshVar();
|
|
3423
|
-
const combined = compose(unify(typeDefs, applyType(s2,
|
|
3403
|
+
const combined = compose(unify(typeDefs, applyType(s2, patternInput_7[1]), new Type_1(/* TFun */ 11, [t2, tv_1]), span_5), compose(s2, s1_2));
|
|
3424
3404
|
const s_1 = compose(constrainMapKeyTypes(typeDefs, span_5, applyType(combined, new Type_1(/* TFun */ 11, [t2, tv_1]))), combined);
|
|
3425
3405
|
const tRes = applyType(s_1, tv_1);
|
|
3426
3406
|
return [s_1, tRes, asTyped(telemetry, expr, tRes)];
|
|
3427
3407
|
}
|
|
3428
3408
|
case 7: {
|
|
3429
3409
|
const span_6 = expr.fields[3];
|
|
3430
|
-
const
|
|
3431
|
-
const s1_3 =
|
|
3432
|
-
const sBool = unify(typeDefs,
|
|
3433
|
-
const
|
|
3434
|
-
const s2_1 =
|
|
3435
|
-
const
|
|
3436
|
-
const tElse =
|
|
3437
|
-
const s3_1 =
|
|
3438
|
-
const s_2 = compose(unify(typeDefs, applyType(s3_1,
|
|
3410
|
+
const patternInput_9 = inferExpr(telemetry, typeDefs, constructors, scope, env, expr.fields[0]);
|
|
3411
|
+
const s1_3 = patternInput_9[0];
|
|
3412
|
+
const sBool = unify(typeDefs, patternInput_9[1], Type_1.TBool, span_6);
|
|
3413
|
+
const patternInput_10 = inferExpr(telemetry, typeDefs, constructors, scope, applyEnv(compose(sBool, s1_3), env), expr.fields[1]);
|
|
3414
|
+
const s2_1 = patternInput_10[0];
|
|
3415
|
+
const patternInput_11 = inferExpr(telemetry, typeDefs, constructors, scope, applyEnv(compose(s2_1, compose(sBool, s1_3)), env), expr.fields[2]);
|
|
3416
|
+
const tElse = patternInput_11[1];
|
|
3417
|
+
const s3_1 = patternInput_11[0];
|
|
3418
|
+
const s_2 = compose(unify(typeDefs, applyType(s3_1, patternInput_10[1]), tElse, span_6), compose(s3_1, compose(s2_1, compose(sBool, s1_3))));
|
|
3439
3419
|
const tRes_1 = applyType(s_2, tElse);
|
|
3440
3420
|
return [s_2, tRes_1, asTyped(telemetry, expr, tRes_1)];
|
|
3441
3421
|
}
|
|
3442
3422
|
case 8: {
|
|
3443
|
-
const
|
|
3444
|
-
const s1_4 =
|
|
3445
|
-
const s_3 = compose(unify(typeDefs, applyType(s1_4,
|
|
3423
|
+
const patternInput_12 = inferExpr(telemetry, typeDefs, constructors, scope, env, expr.fields[0]);
|
|
3424
|
+
const s1_4 = patternInput_12[0];
|
|
3425
|
+
const s_3 = compose(unify(typeDefs, applyType(s1_4, patternInput_12[1]), Type_1.TString, expr.fields[1]), s1_4);
|
|
3446
3426
|
const tRes_2 = Types_freshVar();
|
|
3447
3427
|
return [s_3, tRes_2, asTyped(telemetry, expr, tRes_2)];
|
|
3448
3428
|
}
|
|
3449
3429
|
case 9: {
|
|
3450
|
-
const
|
|
3430
|
+
const name_7 = expr.fields[0];
|
|
3451
3431
|
const body_1 = expr.fields[2];
|
|
3452
|
-
const
|
|
3453
|
-
const s1_5 =
|
|
3432
|
+
const patternInput_13 = inferExpr(telemetry, typeDefs, constructors, scope, env, expr.fields[1]);
|
|
3433
|
+
const s1_5 = patternInput_13[0];
|
|
3454
3434
|
const tv_2 = Types_freshVar();
|
|
3455
|
-
const sSource = compose(unify(typeDefs, applyType(s1_5,
|
|
3456
|
-
const
|
|
3457
|
-
const
|
|
3458
|
-
const
|
|
3459
|
-
|
|
3435
|
+
const sSource = compose(unify(typeDefs, applyType(s1_5, patternInput_13[1]), new Type_1(/* TList */ 5, [tv_2]), expr.fields[3]), s1_5);
|
|
3436
|
+
const itemType = applyType(sSource, tv_2);
|
|
3437
|
+
const envBody = InferenceEnv__AddValue_Z1D943954(applyEnv(sSource, env), name_7, new Scheme(empty_2(), itemType), applyOpaqueEffect(sSource, effectOf(patternInput_13[2])));
|
|
3438
|
+
const patternInput_14 = withLocalBindings(telemetry, singleton(name_7), () => inferExpr(telemetry, typeDefs, constructors, scope, envBody, body_1));
|
|
3439
|
+
const s2_3 = patternInput_14[0];
|
|
3440
|
+
return [compose(unify(typeDefs, applyType(s2_3, patternInput_14[1]), Type_1.TUnit, Ast_spanOfExpr(body_1)), compose(s2_3, sSource)), Type_1.TUnit, asTyped(telemetry, expr, Type_1.TUnit)];
|
|
3460
3441
|
}
|
|
3461
3442
|
case 11: {
|
|
3462
|
-
const
|
|
3443
|
+
const value_5 = expr.fields[1];
|
|
3463
3444
|
const span_9 = expr.fields[6];
|
|
3464
|
-
const
|
|
3445
|
+
const name_8 = expr.fields[0];
|
|
3465
3446
|
const body_2 = expr.fields[2];
|
|
3466
3447
|
const arity = expr.fields[5] | 0;
|
|
3467
|
-
const
|
|
3468
|
-
const valueScope =
|
|
3469
|
-
const returnAnnotation_1 =
|
|
3470
|
-
const explicitParameters =
|
|
3448
|
+
const patternInput_15 = bindingScope(scope, expr.fields[4]);
|
|
3449
|
+
const valueScope = patternInput_15[0];
|
|
3450
|
+
const returnAnnotation_1 = patternInput_15[2];
|
|
3451
|
+
const explicitParameters = patternInput_15[1];
|
|
3471
3452
|
if (expr.fields[3]) {
|
|
3472
3453
|
const tv_3 = Types_freshVar();
|
|
3473
|
-
const envRec =
|
|
3474
|
-
const
|
|
3475
|
-
const
|
|
3476
|
-
const
|
|
3454
|
+
const envRec = InferenceEnv__Add_Z72D39050(env, name_8, new Scheme(empty_2(), tv_3));
|
|
3455
|
+
const patternInput_16 = withLocalBindings(telemetry, singleton(name_8), () => inferExpr(telemetry, typeDefs, constructors, valueScope, envRec, value_5));
|
|
3456
|
+
const valueInfo = patternInput_16[2];
|
|
3457
|
+
const t1_2 = patternInput_16[1];
|
|
3458
|
+
const s1_6 = patternInput_16[0];
|
|
3477
3459
|
const s2_4 = unify(typeDefs, applyType(s1_6, tv_3), t1_2, span_9);
|
|
3478
3460
|
const sValue = compose((returnAnnotation_1 == null) ? emptySubst : ((expectedReturn = scopedAnnotation(valueScope, typeDefs, span_9, returnAnnotation_1), unify(typeDefs, functionReturnType(arity, applyType(s2_4, t1_2)), expectedReturn, span_9))), compose(s2_4, s1_6));
|
|
3479
3461
|
const env1 = applyEnv(sValue, env);
|
|
3480
|
-
const env2_2 =
|
|
3481
|
-
const
|
|
3482
|
-
const tBody_2 =
|
|
3483
|
-
return [compose(
|
|
3462
|
+
const env2_2 = InferenceEnv__AddValue_Z1D943954(env1, name_8, generalizeValue(typeDefs, applyOpaqueEffect(sValue, effectOf(valueInfo)), (inferred) => generalizeBinding(scope, env1.Schemes, sValue, explicitParameters, inferred, span_9), applyType(sValue, t1_2)), applyOpaqueEffect(sValue, effectOf(valueInfo)));
|
|
3463
|
+
const patternInput_17 = withLocalBindings(telemetry, singleton(name_8), () => inferExpr(telemetry, typeDefs, constructors, scope, env2_2, body_2));
|
|
3464
|
+
const tBody_2 = patternInput_17[1];
|
|
3465
|
+
return [compose(patternInput_17[0], sValue), tBody_2, asTyped(telemetry, expr, tBody_2)];
|
|
3484
3466
|
}
|
|
3485
3467
|
else {
|
|
3486
|
-
const
|
|
3487
|
-
const
|
|
3488
|
-
const
|
|
3489
|
-
const
|
|
3468
|
+
const patternInput_18 = inferExpr(telemetry, typeDefs, constructors, valueScope, env, value_5);
|
|
3469
|
+
const valueInfo_1 = patternInput_18[2];
|
|
3470
|
+
const t1_3 = patternInput_18[1];
|
|
3471
|
+
const s1_7 = patternInput_18[0];
|
|
3472
|
+
const sDiscard = (name_8 === "_") ? unify(typeDefs, applyType(s1_7, t1_3), Type_1.TUnit, Ast_spanOfExpr(value_5)) : emptySubst;
|
|
3490
3473
|
const sValue_1 = compose((returnAnnotation_1 == null) ? emptySubst : ((expectedReturn_1 = scopedAnnotation(valueScope, typeDefs, span_9, returnAnnotation_1), unify(typeDefs, functionReturnType(arity, applyType(sDiscard, t1_3)), expectedReturn_1, span_9))), compose(sDiscard, s1_7));
|
|
3491
3474
|
const env1_1 = applyEnv(sValue_1, env);
|
|
3492
|
-
const env2_3 =
|
|
3493
|
-
const
|
|
3494
|
-
const t2_1 =
|
|
3495
|
-
return [compose(
|
|
3475
|
+
const env2_3 = InferenceEnv__AddValue_Z1D943954(env1_1, name_8, generalizeValue(typeDefs, applyOpaqueEffect(sValue_1, effectOf(valueInfo_1)), (inferred_1) => generalizeBinding(scope, env1_1.Schemes, sValue_1, explicitParameters, inferred_1, span_9), applyType(sValue_1, t1_3)), applyOpaqueEffect(sValue_1, effectOf(valueInfo_1)));
|
|
3476
|
+
const patternInput_19 = withLocalBindings(telemetry, singleton(name_8), () => inferExpr(telemetry, typeDefs, constructors, scope, env2_3, body_2));
|
|
3477
|
+
const t2_1 = patternInput_19[1];
|
|
3478
|
+
return [compose(patternInput_19[0], sValue_1), t2_1, asTyped(telemetry, expr, t2_1)];
|
|
3496
3479
|
}
|
|
3497
3480
|
}
|
|
3498
3481
|
case 12: {
|
|
3499
|
-
const value_6 = expr.fields[1];
|
|
3500
3482
|
const startIndex = currentTelemetryCaptureCount(telemetry) | 0;
|
|
3501
|
-
const
|
|
3502
|
-
const
|
|
3503
|
-
const
|
|
3504
|
-
const
|
|
3483
|
+
const patternInput_20 = inferExpr(telemetry, typeDefs, constructors, scope, env, expr.fields[1]);
|
|
3484
|
+
const valueInfo_2 = patternInput_20[2];
|
|
3485
|
+
const s1_8 = patternInput_20[0];
|
|
3486
|
+
const patternInput_21 = inferPattern(telemetry, typeDefs, constructors, expr.fields[0]);
|
|
3487
|
+
const sValue_2 = compose(unify(typeDefs, applyType(s1_8, patternInput_20[1]), patternInput_21[1], expr.fields[3]), s1_8);
|
|
3505
3488
|
applySubstToCapturedLocals(telemetry, startIndex, sValue_2);
|
|
3506
3489
|
const env1_2 = applyEnv(sValue_2, env);
|
|
3507
|
-
const envPatTyped = map((_arg_1, ty) => applyType(sValue_2, ty),
|
|
3508
|
-
const env2_4 = fold_1((
|
|
3509
|
-
const
|
|
3510
|
-
const tBody_3 =
|
|
3511
|
-
return [compose(
|
|
3490
|
+
const envPatTyped = map((_arg_1, ty) => applyType(sValue_2, ty), patternInput_21[0]);
|
|
3491
|
+
const env2_4 = fold_1((state_1, name_9, bindingType) => InferenceEnv__AddValue_Z1D943954(state_1, name_9, generalizeValue(typeDefs, applyOpaqueEffect(sValue_2, effectOf(valueInfo_2)), (t_4) => Types_generalize(env1_2.Schemes, t_4), bindingType), applyOpaqueEffect(sValue_2, effectOf(valueInfo_2))), env1_2, envPatTyped);
|
|
3492
|
+
const patternInput_22 = withLocalBindings(telemetry, map_1((tuple) => tuple[0], toList(envPatTyped)), () => inferExpr(telemetry, typeDefs, constructors, scope, env2_4, expr.fields[2]));
|
|
3493
|
+
const tBody_3 = patternInput_22[1];
|
|
3494
|
+
return [compose(patternInput_22[0], sValue_2), tBody_3, asTyped(telemetry, expr, tBody_3)];
|
|
3512
3495
|
}
|
|
3513
3496
|
case 13: {
|
|
3514
|
-
const foldedBindings = map_1((
|
|
3515
|
-
const args =
|
|
3516
|
-
const bindingSpan =
|
|
3497
|
+
const foldedBindings = map_1((tupledArg_2) => {
|
|
3498
|
+
const args = tupledArg_2[1];
|
|
3499
|
+
const bindingSpan = tupledArg_2[4];
|
|
3517
3500
|
if (isEmpty_1(args)) {
|
|
3518
3501
|
throw new TypeException(new TypeError$("\'let rec ... and ...\' requires function arguments for each binding", bindingSpan));
|
|
3519
3502
|
}
|
|
3520
|
-
const folded = foldBack((arg_4, acc) => (new Expr(/* ELambda */ 5, [arg_4, acc, bindingSpan])), args,
|
|
3521
|
-
return [
|
|
3503
|
+
const folded = foldBack((arg_4, acc) => (new Expr(/* ELambda */ 5, [arg_4, acc, bindingSpan])), args, tupledArg_2[3]);
|
|
3504
|
+
return [tupledArg_2[0], bindingScope(scope, tupledArg_2[2]), folded, length(args), bindingSpan];
|
|
3522
3505
|
}, expr.fields[0]);
|
|
3523
|
-
const freshByName = ofList(map_1((
|
|
3524
|
-
Compare: (
|
|
3506
|
+
const freshByName = ofList(map_1((tupledArg_3) => [tupledArg_3[0], Types_freshVar()], foldedBindings), {
|
|
3507
|
+
Compare: (x_3, y_3) => (comparePrimitives(x_3, y_3) | 0),
|
|
3525
3508
|
});
|
|
3526
|
-
const envRec_1 = fold_1((acc_1,
|
|
3509
|
+
const envRec_1 = fold_1((acc_1, name_12, tv_4) => InferenceEnv__Add_Z72D39050(acc_1, name_12, new Scheme(empty_2(), tv_4)), env, freshByName);
|
|
3527
3510
|
let sRec = emptySubst;
|
|
3511
|
+
const groupEffects = [];
|
|
3528
3512
|
const recursiveNames = map_1((tuple_1) => tuple_1[0], toList(freshByName));
|
|
3529
3513
|
withLocalBindings(telemetry, recursiveNames, () => {
|
|
3530
3514
|
const enumerator_1 = getEnumerator(foldedBindings);
|
|
3531
3515
|
try {
|
|
3532
3516
|
while (enumerator_1["System.Collections.IEnumerator.MoveNext"]()) {
|
|
3533
3517
|
const forLoopVar = enumerator_1["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
3534
|
-
const
|
|
3535
|
-
const s1_9 =
|
|
3536
|
-
|
|
3518
|
+
const patternInput_23 = inferExpr(telemetry, typeDefs, constructors, forLoopVar[1][0], applyEnv(sRec, envRec_1), forLoopVar[2]);
|
|
3519
|
+
const s1_9 = patternInput_23[0];
|
|
3520
|
+
void (groupEffects.push(effectOf(patternInput_23[2])));
|
|
3521
|
+
const s2_7 = unify(typeDefs, applyType(s1_9, applyType(sRec, FSharpMap__get_Item(freshByName, forLoopVar[0]))), patternInput_23[1], forLoopVar[4]);
|
|
3537
3522
|
sRec = compose(s2_7, compose(s1_9, sRec));
|
|
3538
3523
|
}
|
|
3539
3524
|
}
|
|
@@ -3560,20 +3545,22 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
|
3560
3545
|
disposeSafe(enumerator_2);
|
|
3561
3546
|
}
|
|
3562
3547
|
const envGeneralize = applyEnv(sRec, env);
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3548
|
+
let groupEffect;
|
|
3549
|
+
const effect_13 = recursiveOpaqueEffects(groupEffects);
|
|
3550
|
+
groupEffect = applyOpaqueEffect(sRec, effect_13);
|
|
3551
|
+
const envBody_1 = fold((acc_2, tupledArg_5) => InferenceEnv__AddValue_Z1D943954(acc_2, tupledArg_5[0], tupledArg_5[1], groupEffect), envGeneralize, map_1((tupledArg_4) => {
|
|
3552
|
+
const name_15 = tupledArg_4[0];
|
|
3553
|
+
return [name_15, generalizeValue(typeDefs, groupEffect, (typ_1) => generalizeBinding(scope, envGeneralize.Schemes, sRec, tupledArg_4[1][1], typ_1, tupledArg_4[4]), applyType(sRec, FSharpMap__get_Item(freshByName, name_15)))];
|
|
3567
3554
|
}, foldedBindings));
|
|
3568
|
-
const
|
|
3569
|
-
const tBody_4 =
|
|
3570
|
-
return [compose(
|
|
3555
|
+
const patternInput_24 = withLocalBindings(telemetry, recursiveNames, () => inferExpr(telemetry, typeDefs, constructors, scope, envBody_1, expr.fields[1]));
|
|
3556
|
+
const tBody_4 = patternInput_24[1];
|
|
3557
|
+
return [compose(patternInput_24[0], sRec), tBody_4, asTyped(telemetry, expr, tBody_4)];
|
|
3571
3558
|
}
|
|
3572
3559
|
case 10: {
|
|
3573
3560
|
const cases = expr.fields[1];
|
|
3574
|
-
const
|
|
3575
|
-
const tScrut =
|
|
3576
|
-
let sAcc_1 =
|
|
3561
|
+
const patternInput_25 = inferExpr(telemetry, typeDefs, constructors, scope, env, expr.fields[0]);
|
|
3562
|
+
const tScrut = patternInput_25[1];
|
|
3563
|
+
let sAcc_1 = patternInput_25[0];
|
|
3577
3564
|
let resultTypeOpt = undefined;
|
|
3578
3565
|
const enumerator_3 = getEnumerator(cases);
|
|
3579
3566
|
try {
|
|
@@ -3582,27 +3569,30 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
|
3582
3569
|
const forLoopVar_2 = enumerator_3["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
3583
3570
|
const guard = forLoopVar_2[1];
|
|
3584
3571
|
const caseSpan = forLoopVar_2[3];
|
|
3585
|
-
const
|
|
3586
|
-
const envPat_1 =
|
|
3587
|
-
const sPat = unify(typeDefs, applyType(sAcc_1, tScrut),
|
|
3572
|
+
const patternInput_26 = inferPattern(telemetry, typeDefs, constructors, forLoopVar_2[0]);
|
|
3573
|
+
const envPat_1 = patternInput_26[0];
|
|
3574
|
+
const sPat = unify(typeDefs, applyType(sAcc_1, tScrut), patternInput_26[1], caseSpan);
|
|
3588
3575
|
applyAnnotationScope(scope, sPat);
|
|
3589
|
-
const envCase$0027 = fold_1((acc_3, k, v) =>
|
|
3590
|
-
|
|
3576
|
+
const envCase$0027 = fold_1((acc_3, k, v) => {
|
|
3577
|
+
let effect_14;
|
|
3578
|
+
return InferenceEnv__AddValue_Z1D943954(acc_3, k, new Scheme(empty_2(), applyType(sPat, v)), (effect_14 = effectOf(patternInput_25[2]), applyOpaqueEffect(compose(sPat, sAcc_1), effect_14)));
|
|
3579
|
+
}, applyEnv(compose(sPat, sAcc_1), env), envPat_1);
|
|
3580
|
+
const patternInput_28 = withLocalBindings(telemetry, map_1((tuple_2) => tuple_2[0], toList(envPat_1)), () => {
|
|
3591
3581
|
let envBodyCase = envCase$0027;
|
|
3592
3582
|
if (guard == null) {
|
|
3593
3583
|
}
|
|
3594
3584
|
else {
|
|
3595
3585
|
const guardExpr = guard;
|
|
3596
|
-
const
|
|
3597
|
-
const sGuard =
|
|
3598
|
-
const sGuardBool = unify(typeDefs, applyType(sGuard,
|
|
3586
|
+
const patternInput_27 = inferExpr(telemetry, typeDefs, constructors, scope, envBodyCase, guardExpr);
|
|
3587
|
+
const sGuard = patternInput_27[0];
|
|
3588
|
+
const sGuardBool = unify(typeDefs, applyType(sGuard, patternInput_27[1]), Type_1.TBool, caseSpan);
|
|
3599
3589
|
sAcc_1 = compose(sGuardBool, compose(sGuard, sAcc_1));
|
|
3600
3590
|
envBodyCase = applyEnv(compose(sGuardBool, sGuard), envBodyCase);
|
|
3601
3591
|
}
|
|
3602
3592
|
return inferExpr(telemetry, typeDefs, constructors, scope, envBodyCase, forLoopVar_2[2]);
|
|
3603
3593
|
});
|
|
3604
|
-
const sBody_2 =
|
|
3605
|
-
const tBody$0027 = applyType(sBody_2,
|
|
3594
|
+
const sBody_2 = patternInput_28[0];
|
|
3595
|
+
const tBody$0027 = applyType(sBody_2, patternInput_28[1]);
|
|
3606
3596
|
resultTypeOpt = ((resultTypeOpt != null) ? ((tPrev = resultTypeOpt, (sEq = unify(typeDefs, tPrev, tBody$0027, caseSpan), (sAcc_1 = compose(sEq, sAcc_1), applyType(sEq, tPrev))))) : tBody$0027);
|
|
3607
3597
|
sAcc_1 = compose(sBody_2, compose(sPat, sAcc_1));
|
|
3608
3598
|
}
|
|
@@ -3621,9 +3611,9 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
|
3621
3611
|
try {
|
|
3622
3612
|
while (enumerator_4["System.Collections.IEnumerator.MoveNext"]()) {
|
|
3623
3613
|
const item = enumerator_4["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
3624
|
-
const
|
|
3625
|
-
const itemSubst = compose(
|
|
3626
|
-
const s2_8 = unify(typeDefs, applyType(itemSubst, tv_5), applyType(itemSubst,
|
|
3614
|
+
const patternInput_29 = inferExpr(telemetry, typeDefs, constructors, scope, applyEnv(sAcc_2, env), item);
|
|
3615
|
+
const itemSubst = compose(patternInput_29[0], sAcc_2);
|
|
3616
|
+
const s2_8 = unify(typeDefs, applyType(itemSubst, tv_5), applyType(itemSubst, patternInput_29[1]), expr.fields[1]);
|
|
3627
3617
|
sAcc_2 = compose(s2_8, itemSubst);
|
|
3628
3618
|
}
|
|
3629
3619
|
}
|
|
@@ -3635,13 +3625,13 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
|
3635
3625
|
}
|
|
3636
3626
|
case 15: {
|
|
3637
3627
|
const span_14 = expr.fields[2];
|
|
3638
|
-
const
|
|
3639
|
-
const s1_12 =
|
|
3640
|
-
const
|
|
3641
|
-
const s2_9 =
|
|
3642
|
-
const s3_3 = unify(typeDefs, applyType(s2_9,
|
|
3628
|
+
const patternInput_30 = inferExpr(telemetry, typeDefs, constructors, scope, env, expr.fields[0]);
|
|
3629
|
+
const s1_12 = patternInput_30[0];
|
|
3630
|
+
const patternInput_31 = inferExpr(telemetry, typeDefs, constructors, scope, applyEnv(s1_12, env), expr.fields[1]);
|
|
3631
|
+
const s2_9 = patternInput_31[0];
|
|
3632
|
+
const s3_3 = unify(typeDefs, applyType(s2_9, patternInput_30[1]), Type_1.TInt, span_14);
|
|
3643
3633
|
const tRes_5 = new Type_1(/* TList */ 5, [Type_1.TInt]);
|
|
3644
|
-
return [compose(unify(typeDefs, applyType(s3_3, applyType(s2_9,
|
|
3634
|
+
return [compose(unify(typeDefs, applyType(s3_3, applyType(s2_9, patternInput_31[1])), Type_1.TInt, span_14), compose(s3_3, compose(s2_9, s1_12))), tRes_5, asTyped(telemetry, expr, tRes_5)];
|
|
3645
3635
|
}
|
|
3646
3636
|
case 16: {
|
|
3647
3637
|
let sAcc_3 = emptySubst;
|
|
@@ -3650,9 +3640,9 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
|
3650
3640
|
try {
|
|
3651
3641
|
while (enumerator_5["System.Collections.IEnumerator.MoveNext"]()) {
|
|
3652
3642
|
const item_1 = enumerator_5["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
3653
|
-
const
|
|
3654
|
-
sAcc_3 = compose(
|
|
3655
|
-
inferred_3 = cons(applyType(sAcc_3,
|
|
3643
|
+
const patternInput_32 = inferExpr(telemetry, typeDefs, constructors, scope, applyEnv(sAcc_3, env), item_1);
|
|
3644
|
+
sAcc_3 = compose(patternInput_32[0], sAcc_3);
|
|
3645
|
+
inferred_3 = cons(applyType(sAcc_3, patternInput_32[1]), inferred_3);
|
|
3656
3646
|
}
|
|
3657
3647
|
}
|
|
3658
3648
|
finally {
|
|
@@ -3665,22 +3655,22 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
|
3665
3655
|
const span_15 = expr.fields[1];
|
|
3666
3656
|
let sAcc_4 = emptySubst;
|
|
3667
3657
|
let inferred_4 = empty({
|
|
3668
|
-
Compare: (
|
|
3658
|
+
Compare: (x_4, y_4) => (comparePrimitives(x_4, y_4) | 0),
|
|
3669
3659
|
});
|
|
3670
3660
|
const enumerator_6 = getEnumerator(expr.fields[0]);
|
|
3671
3661
|
try {
|
|
3672
3662
|
while (enumerator_6["System.Collections.IEnumerator.MoveNext"]()) {
|
|
3673
3663
|
const forLoopVar_3 = enumerator_6["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
3674
|
-
const
|
|
3675
|
-
sAcc_4 = compose(
|
|
3676
|
-
inferred_4 = FSharpMap__Add(inferred_4, forLoopVar_3[0], applyType(sAcc_4,
|
|
3664
|
+
const patternInput_33 = inferExpr(telemetry, typeDefs, constructors, scope, applyEnv(sAcc_4, env), forLoopVar_3[1]);
|
|
3665
|
+
sAcc_4 = compose(patternInput_33[0], sAcc_4);
|
|
3666
|
+
inferred_4 = FSharpMap__Add(inferred_4, forLoopVar_3[0], applyType(sAcc_4, patternInput_33[1]));
|
|
3677
3667
|
}
|
|
3678
3668
|
}
|
|
3679
3669
|
finally {
|
|
3680
3670
|
disposeSafe(enumerator_6);
|
|
3681
3671
|
}
|
|
3682
3672
|
const recordTypeName = resolveNamedRecordByFieldSet(typeDefs, ofSeq(keys(inferred_4), {
|
|
3683
|
-
Compare: (
|
|
3673
|
+
Compare: (x_5, y_5) => (comparePrimitives(x_5, y_5) | 0),
|
|
3684
3674
|
}), span_15);
|
|
3685
3675
|
const expected_1 = Types_applied(recordTypeName, FSharpMap__get_Item(typeDefs, recordTypeName));
|
|
3686
3676
|
const s_10 = compose(unify(typeDefs, applyType(sAcc_4, new Type_1(/* TRecord */ 8, [inferred_4])), expected_1, span_15), sAcc_4);
|
|
@@ -3690,15 +3680,15 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
|
3690
3680
|
case 18: {
|
|
3691
3681
|
let sAcc_5 = emptySubst;
|
|
3692
3682
|
let inferred_5 = empty({
|
|
3693
|
-
Compare: (
|
|
3683
|
+
Compare: (x_6, y_6) => (comparePrimitives(x_6, y_6) | 0),
|
|
3694
3684
|
});
|
|
3695
3685
|
const enumerator_7 = getEnumerator(expr.fields[0]);
|
|
3696
3686
|
try {
|
|
3697
3687
|
while (enumerator_7["System.Collections.IEnumerator.MoveNext"]()) {
|
|
3698
3688
|
const forLoopVar_4 = enumerator_7["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
3699
|
-
const
|
|
3700
|
-
sAcc_5 = compose(
|
|
3701
|
-
inferred_5 = FSharpMap__Add(inferred_5, forLoopVar_4[0], applyType(sAcc_5,
|
|
3689
|
+
const patternInput_34 = inferExpr(telemetry, typeDefs, constructors, scope, applyEnv(sAcc_5, env), forLoopVar_4[1]);
|
|
3690
|
+
sAcc_5 = compose(patternInput_34[0], sAcc_5);
|
|
3691
|
+
inferred_5 = FSharpMap__Add(inferred_5, forLoopVar_4[0], applyType(sAcc_5, patternInput_34[1]));
|
|
3702
3692
|
}
|
|
3703
3693
|
}
|
|
3704
3694
|
finally {
|
|
@@ -3720,22 +3710,22 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
|
3720
3710
|
const entry = enumerator_8["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
3721
3711
|
if (entry.tag === 1) {
|
|
3722
3712
|
const spreadExpr = entry.fields[0];
|
|
3723
|
-
const
|
|
3724
|
-
const sSpread =
|
|
3713
|
+
const patternInput_37 = inferExpr(telemetry, typeDefs, constructors, scope, applyEnv(sAcc_6, env), spreadExpr);
|
|
3714
|
+
const sSpread = patternInput_37[0];
|
|
3725
3715
|
const expectedSpreadType = new Type_1(/* TMap */ 9, [applyType(sSpread, applyType(sAcc_6, keyType)), applyType(sSpread, applyType(sAcc_6, valueType))]);
|
|
3726
|
-
const sSpreadMap = unify(typeDefs, applyType(sSpread,
|
|
3716
|
+
const sSpreadMap = unify(typeDefs, applyType(sSpread, patternInput_37[1]), expectedSpreadType, Ast_spanOfExpr(spreadExpr));
|
|
3727
3717
|
sAcc_6 = compose(sSpreadMap, compose(sSpread, sAcc_6));
|
|
3728
3718
|
}
|
|
3729
3719
|
else {
|
|
3730
3720
|
const valueExpr_3 = entry.fields[1];
|
|
3731
3721
|
const keyExpr = entry.fields[0];
|
|
3732
|
-
const
|
|
3733
|
-
const sKey =
|
|
3734
|
-
const sAfterKey = compose(unify(typeDefs, applyType(sKey,
|
|
3722
|
+
const patternInput_35 = inferExpr(telemetry, typeDefs, constructors, scope, applyEnv(sAcc_6, env), keyExpr);
|
|
3723
|
+
const sKey = patternInput_35[0];
|
|
3724
|
+
const sAfterKey = compose(unify(typeDefs, applyType(sKey, patternInput_35[1]), applyType(sKey, applyType(sAcc_6, keyType)), Ast_spanOfExpr(keyExpr)), compose(sKey, sAcc_6));
|
|
3735
3725
|
ensureSupportedMapKeyType_1(applyType(sAfterKey, keyType));
|
|
3736
|
-
const
|
|
3737
|
-
const sValue_3 =
|
|
3738
|
-
const sValueType = unify(typeDefs, applyType(sValue_3, applyType(sAfterKey, valueType)),
|
|
3726
|
+
const patternInput_36 = inferExpr(telemetry, typeDefs, constructors, scope, applyEnv(sAfterKey, env), valueExpr_3);
|
|
3727
|
+
const sValue_3 = patternInput_36[0];
|
|
3728
|
+
const sValueType = unify(typeDefs, applyType(sValue_3, applyType(sAfterKey, valueType)), patternInput_36[1], Ast_spanOfExpr(valueExpr_3));
|
|
3739
3729
|
sAcc_6 = compose(sValueType, compose(sValue_3, sAfterKey));
|
|
3740
3730
|
}
|
|
3741
3731
|
}
|
|
@@ -3749,32 +3739,32 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
|
3749
3739
|
}
|
|
3750
3740
|
case 20: {
|
|
3751
3741
|
const span_17 = expr.fields[2];
|
|
3752
|
-
const
|
|
3753
|
-
const tBase =
|
|
3754
|
-
const sInitial =
|
|
3742
|
+
const patternInput_38 = inferExpr(telemetry, typeDefs, constructors, scope, env, expr.fields[0]);
|
|
3743
|
+
const tBase = patternInput_38[1];
|
|
3744
|
+
const sInitial = patternInput_38[0];
|
|
3755
3745
|
let sBase;
|
|
3756
|
-
const
|
|
3757
|
-
if (
|
|
3758
|
-
const id =
|
|
3759
|
-
sBase = compose(ofList(singleton([id, new Type_1(/* TRecordShape */ 20, [id,
|
|
3760
|
-
Compare: (
|
|
3746
|
+
const matchValue_6 = applyType(sInitial, tBase);
|
|
3747
|
+
if (matchValue_6.tag === 20) {
|
|
3748
|
+
const id = matchValue_6.fields[0] | 0;
|
|
3749
|
+
sBase = compose(ofList(singleton([id, new Type_1(/* TRecordShape */ 20, [id, matchValue_6.fields[1], true])]), {
|
|
3750
|
+
Compare: (x_7, y_7) => (comparePrimitives(x_7, y_7) | 0),
|
|
3761
3751
|
}), sInitial);
|
|
3762
3752
|
}
|
|
3763
3753
|
else {
|
|
3764
3754
|
sBase = sInitial;
|
|
3765
3755
|
}
|
|
3766
3756
|
let baseFields;
|
|
3767
|
-
const
|
|
3757
|
+
const matchValue_7 = Types_expand(typeDefs, applyType(sBase, tBase));
|
|
3768
3758
|
let matchResult, fields_3;
|
|
3769
|
-
switch (
|
|
3759
|
+
switch (matchValue_7.tag) {
|
|
3770
3760
|
case 8: {
|
|
3771
3761
|
matchResult = 0;
|
|
3772
|
-
fields_3 =
|
|
3762
|
+
fields_3 = matchValue_7.fields[0];
|
|
3773
3763
|
break;
|
|
3774
3764
|
}
|
|
3775
3765
|
case 20: {
|
|
3776
3766
|
matchResult = 0;
|
|
3777
|
-
fields_3 =
|
|
3767
|
+
fields_3 = matchValue_7.fields[1];
|
|
3778
3768
|
break;
|
|
3779
3769
|
}
|
|
3780
3770
|
case 12: {
|
|
@@ -3790,14 +3780,14 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
|
3790
3780
|
break;
|
|
3791
3781
|
}
|
|
3792
3782
|
case 1: {
|
|
3793
|
-
const
|
|
3794
|
-
const
|
|
3783
|
+
const name_19 = matchValue_7.fields[0];
|
|
3784
|
+
const matchValue_8 = FSharpMap__TryFind(typeDefs, name_19);
|
|
3795
3785
|
let matchResult_1, fields_4;
|
|
3796
|
-
if (
|
|
3797
|
-
switch (
|
|
3786
|
+
if (matchValue_8 != null) {
|
|
3787
|
+
switch (matchValue_8.tag) {
|
|
3798
3788
|
case 8: {
|
|
3799
3789
|
matchResult_1 = 0;
|
|
3800
|
-
fields_4 =
|
|
3790
|
+
fields_4 = matchValue_8.fields[0];
|
|
3801
3791
|
break;
|
|
3802
3792
|
}
|
|
3803
3793
|
case 19: {
|
|
@@ -3817,7 +3807,7 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
|
3817
3807
|
break;
|
|
3818
3808
|
}
|
|
3819
3809
|
case 1: {
|
|
3820
|
-
throw new TypeException(new TypeError$(concat("Host-managed type \'",
|
|
3810
|
+
throw new TypeException(new TypeError$(concat("Host-managed type \'", name_19, "\' cannot be updated"), span_17));
|
|
3821
3811
|
break;
|
|
3822
3812
|
}
|
|
3823
3813
|
default:
|
|
@@ -3834,18 +3824,18 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
|
3834
3824
|
while (enumerator_9["System.Collections.IEnumerator.MoveNext"]()) {
|
|
3835
3825
|
const forLoopVar_5 = enumerator_9["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
3836
3826
|
const valueExpr_4 = forLoopVar_5[1];
|
|
3837
|
-
const
|
|
3827
|
+
const name_20 = forLoopVar_5[0];
|
|
3838
3828
|
let expectedFieldType;
|
|
3839
|
-
const
|
|
3840
|
-
if (
|
|
3841
|
-
throw new TypeException(new TypeError$(toText(printf("Record field \'%s\' not found"))(
|
|
3829
|
+
const matchValue_9 = FSharpMap__TryFind(baseFields, name_20);
|
|
3830
|
+
if (matchValue_9 == null) {
|
|
3831
|
+
throw new TypeException(new TypeError$(toText(printf("Record field \'%s\' not found"))(name_20), Ast_spanOfExpr(valueExpr_4)));
|
|
3842
3832
|
}
|
|
3843
3833
|
else {
|
|
3844
|
-
expectedFieldType =
|
|
3834
|
+
expectedFieldType = matchValue_9;
|
|
3845
3835
|
}
|
|
3846
|
-
const
|
|
3847
|
-
const sField =
|
|
3848
|
-
const sEq_1 = unify(typeDefs, applyType(sField, applyType(sAcc_7, expectedFieldType)),
|
|
3836
|
+
const patternInput_39 = inferExpr(telemetry, typeDefs, constructors, scope, applyEnv(sAcc_7, env), valueExpr_4);
|
|
3837
|
+
const sField = patternInput_39[0];
|
|
3838
|
+
const sEq_1 = unify(typeDefs, applyType(sField, applyType(sAcc_7, expectedFieldType)), patternInput_39[1], Ast_spanOfExpr(valueExpr_4));
|
|
3849
3839
|
sAcc_7 = compose(sEq_1, compose(sField, sAcc_7));
|
|
3850
3840
|
}
|
|
3851
3841
|
}
|
|
@@ -3854,21 +3844,21 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
|
3854
3844
|
}
|
|
3855
3845
|
const resultFields = map((_arg_9, t_7) => applyType(sAcc_7, t_7), baseFields);
|
|
3856
3846
|
let tRes_10;
|
|
3857
|
-
const
|
|
3858
|
-
tRes_10 = ((
|
|
3847
|
+
const matchValue_10 = applyType(sAcc_7, tBase);
|
|
3848
|
+
tRes_10 = ((matchValue_10.tag === 13) ? matchValue_10 : (new Type_1(/* TRecord */ 8, [resultFields])));
|
|
3859
3849
|
return [sAcc_7, tRes_10, asTyped(telemetry, expr, tRes_10)];
|
|
3860
3850
|
}
|
|
3861
3851
|
case 21: {
|
|
3862
3852
|
const span_18 = expr.fields[2];
|
|
3863
|
-
const
|
|
3864
|
-
const tBase_1 =
|
|
3865
|
-
const sInitial_1 =
|
|
3853
|
+
const patternInput_40 = inferExpr(telemetry, typeDefs, constructors, scope, env, expr.fields[0]);
|
|
3854
|
+
const tBase_1 = patternInput_40[1];
|
|
3855
|
+
const sInitial_1 = patternInput_40[0];
|
|
3866
3856
|
let sBase_1;
|
|
3867
|
-
const
|
|
3868
|
-
if (
|
|
3869
|
-
const id_1 =
|
|
3870
|
-
sBase_1 = compose(ofList(singleton([id_1, new Type_1(/* TRecordShape */ 20, [id_1,
|
|
3871
|
-
Compare: (
|
|
3857
|
+
const matchValue_11 = applyType(sInitial_1, tBase_1);
|
|
3858
|
+
if (matchValue_11.tag === 20) {
|
|
3859
|
+
const id_1 = matchValue_11.fields[0] | 0;
|
|
3860
|
+
sBase_1 = compose(ofList(singleton([id_1, new Type_1(/* TRecordShape */ 20, [id_1, matchValue_11.fields[1], true])]), {
|
|
3861
|
+
Compare: (x_8, y_8) => (comparePrimitives(x_8, y_8) | 0),
|
|
3872
3862
|
}), sInitial_1);
|
|
3873
3863
|
}
|
|
3874
3864
|
else {
|
|
@@ -3876,17 +3866,17 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
|
3876
3866
|
}
|
|
3877
3867
|
let sAcc_8 = sBase_1;
|
|
3878
3868
|
let resultFields_1;
|
|
3879
|
-
const
|
|
3869
|
+
const matchValue_12 = Types_expand(typeDefs, applyType(sBase_1, tBase_1));
|
|
3880
3870
|
let matchResult_2, fields_6;
|
|
3881
|
-
switch (
|
|
3871
|
+
switch (matchValue_12.tag) {
|
|
3882
3872
|
case 8: {
|
|
3883
3873
|
matchResult_2 = 0;
|
|
3884
|
-
fields_6 =
|
|
3874
|
+
fields_6 = matchValue_12.fields[0];
|
|
3885
3875
|
break;
|
|
3886
3876
|
}
|
|
3887
3877
|
case 20: {
|
|
3888
3878
|
matchResult_2 = 0;
|
|
3889
|
-
fields_6 =
|
|
3879
|
+
fields_6 = matchValue_12.fields[1];
|
|
3890
3880
|
break;
|
|
3891
3881
|
}
|
|
3892
3882
|
case 12: {
|
|
@@ -3902,14 +3892,14 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
|
3902
3892
|
break;
|
|
3903
3893
|
}
|
|
3904
3894
|
case 1: {
|
|
3905
|
-
const
|
|
3906
|
-
const
|
|
3895
|
+
const name_21 = matchValue_12.fields[0];
|
|
3896
|
+
const matchValue_13 = FSharpMap__TryFind(typeDefs, name_21);
|
|
3907
3897
|
let matchResult_3, fields_7;
|
|
3908
|
-
if (
|
|
3909
|
-
switch (
|
|
3898
|
+
if (matchValue_13 != null) {
|
|
3899
|
+
switch (matchValue_13.tag) {
|
|
3910
3900
|
case 8: {
|
|
3911
3901
|
matchResult_3 = 0;
|
|
3912
|
-
fields_7 =
|
|
3902
|
+
fields_7 = matchValue_13.fields[0];
|
|
3913
3903
|
break;
|
|
3914
3904
|
}
|
|
3915
3905
|
case 19: {
|
|
@@ -3929,7 +3919,7 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
|
3929
3919
|
break;
|
|
3930
3920
|
}
|
|
3931
3921
|
case 1: {
|
|
3932
|
-
throw new TypeException(new TypeError$(concat("Host-managed type \'",
|
|
3922
|
+
throw new TypeException(new TypeError$(concat("Host-managed type \'", name_21, "\' cannot be updated"), span_18));
|
|
3933
3923
|
break;
|
|
3934
3924
|
}
|
|
3935
3925
|
default:
|
|
@@ -3943,16 +3933,16 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
|
3943
3933
|
const enumerator_10 = getEnumerator(expr.fields[1]);
|
|
3944
3934
|
try {
|
|
3945
3935
|
while (enumerator_10["System.Collections.IEnumerator.MoveNext"]()) {
|
|
3946
|
-
let
|
|
3936
|
+
let matchValue_14, existingFieldType, table_12;
|
|
3947
3937
|
const forLoopVar_6 = enumerator_10["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
3948
3938
|
const valueExpr_5 = forLoopVar_6[1];
|
|
3949
|
-
const
|
|
3950
|
-
const
|
|
3951
|
-
const sField_1 =
|
|
3952
|
-
const tFieldApplied = applyType(sField_1,
|
|
3953
|
-
const sEq_2 = unify(typeDefs, (
|
|
3939
|
+
const name_22 = forLoopVar_6[0];
|
|
3940
|
+
const patternInput_41 = inferExpr(telemetry, typeDefs, constructors, scope, applyEnv(sAcc_8, env), valueExpr_5);
|
|
3941
|
+
const sField_1 = patternInput_41[0];
|
|
3942
|
+
const tFieldApplied = applyType(sField_1, patternInput_41[1]);
|
|
3943
|
+
const sEq_2 = unify(typeDefs, (matchValue_14 = FSharpMap__TryFind(resultFields_1, name_22), (matchValue_14 == null) ? tFieldApplied : ((existingFieldType = matchValue_14, applyType(sField_1, applyType(sAcc_8, existingFieldType))))), tFieldApplied, Ast_spanOfExpr(valueExpr_5));
|
|
3954
3944
|
sAcc_8 = compose(sEq_2, compose(sField_1, sAcc_8));
|
|
3955
|
-
resultFields_1 = ((
|
|
3945
|
+
resultFields_1 = ((table_12 = resultFields_1, add(name_22, applyType(sAcc_8, tFieldApplied), table_12)));
|
|
3956
3946
|
}
|
|
3957
3947
|
}
|
|
3958
3948
|
finally {
|
|
@@ -3966,22 +3956,22 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
|
3966
3956
|
const span_19 = expr.fields[2];
|
|
3967
3957
|
const fieldName = expr.fields[1];
|
|
3968
3958
|
const inferRecordField = (s1_16, tTarget) => {
|
|
3969
|
-
let
|
|
3970
|
-
const
|
|
3959
|
+
let matchValue_20;
|
|
3960
|
+
const matchValue_15 = Types_expand(typeDefs, applyType(s1_16, tTarget));
|
|
3971
3961
|
let matchResult_4, fields_9;
|
|
3972
|
-
switch (
|
|
3962
|
+
switch (matchValue_15.tag) {
|
|
3973
3963
|
case 20: {
|
|
3974
3964
|
matchResult_4 = 0;
|
|
3975
3965
|
break;
|
|
3976
3966
|
}
|
|
3977
3967
|
case 8: {
|
|
3978
3968
|
matchResult_4 = 1;
|
|
3979
|
-
fields_9 =
|
|
3969
|
+
fields_9 = matchValue_15.fields[0];
|
|
3980
3970
|
break;
|
|
3981
3971
|
}
|
|
3982
3972
|
case 19: {
|
|
3983
3973
|
matchResult_4 = 1;
|
|
3984
|
-
fields_9 =
|
|
3974
|
+
fields_9 = matchValue_15.fields[1];
|
|
3985
3975
|
break;
|
|
3986
3976
|
}
|
|
3987
3977
|
case 12: {
|
|
@@ -3997,41 +3987,41 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
|
3997
3987
|
}
|
|
3998
3988
|
switch (matchResult_4) {
|
|
3999
3989
|
case 0: {
|
|
4000
|
-
const id_2 =
|
|
4001
|
-
const fields_8 =
|
|
4002
|
-
const
|
|
4003
|
-
if (
|
|
3990
|
+
const id_2 = matchValue_15.fields[0] | 0;
|
|
3991
|
+
const fields_8 = matchValue_15.fields[1];
|
|
3992
|
+
const matchValue_16 = FSharpMap__TryFind(fields_8, fieldName);
|
|
3993
|
+
if (matchValue_16 == null) {
|
|
4004
3994
|
const tField_3 = Types_freshVar();
|
|
4005
|
-
return [compose(ofList(singleton([id_2, new Type_1(/* TRecordShape */ 20, [id_2, FSharpMap__Add(fields_8, fieldName, tField_3),
|
|
4006
|
-
Compare: (
|
|
3995
|
+
return [compose(ofList(singleton([id_2, new Type_1(/* TRecordShape */ 20, [id_2, FSharpMap__Add(fields_8, fieldName, tField_3), matchValue_15.fields[2]])]), {
|
|
3996
|
+
Compare: (x_9, y_9) => (comparePrimitives(x_9, y_9) | 0),
|
|
4007
3997
|
}), s1_16), tField_3];
|
|
4008
3998
|
}
|
|
4009
3999
|
else {
|
|
4010
|
-
return [s1_16,
|
|
4000
|
+
return [s1_16, matchValue_16];
|
|
4011
4001
|
}
|
|
4012
4002
|
}
|
|
4013
4003
|
case 1: {
|
|
4014
|
-
const
|
|
4015
|
-
if (
|
|
4004
|
+
const matchValue_17 = FSharpMap__TryFind(fields_9, fieldName);
|
|
4005
|
+
if (matchValue_17 == null) {
|
|
4016
4006
|
throw new TypeException(new TypeError$(toText(printf("Record field \'%s\' not found"))(fieldName), span_19));
|
|
4017
4007
|
}
|
|
4018
4008
|
else {
|
|
4019
|
-
return [s1_16,
|
|
4009
|
+
return [s1_16, matchValue_17];
|
|
4020
4010
|
}
|
|
4021
4011
|
}
|
|
4022
4012
|
case 2: {
|
|
4023
|
-
const
|
|
4013
|
+
const matchValue_18 = FSharpMap__TryFind(typeDefs, matchValue_15.fields[0]);
|
|
4024
4014
|
let matchResult_5, fields_10;
|
|
4025
|
-
if (
|
|
4026
|
-
switch (
|
|
4015
|
+
if (matchValue_18 != null) {
|
|
4016
|
+
switch (matchValue_18.tag) {
|
|
4027
4017
|
case 8: {
|
|
4028
4018
|
matchResult_5 = 0;
|
|
4029
|
-
fields_10 =
|
|
4019
|
+
fields_10 = matchValue_18.fields[0];
|
|
4030
4020
|
break;
|
|
4031
4021
|
}
|
|
4032
4022
|
case 19: {
|
|
4033
4023
|
matchResult_5 = 0;
|
|
4034
|
-
fields_10 =
|
|
4024
|
+
fields_10 = matchValue_18.fields[1];
|
|
4035
4025
|
break;
|
|
4036
4026
|
}
|
|
4037
4027
|
default:
|
|
@@ -4043,12 +4033,12 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
|
4043
4033
|
}
|
|
4044
4034
|
switch (matchResult_5) {
|
|
4045
4035
|
case 0: {
|
|
4046
|
-
const
|
|
4047
|
-
if (
|
|
4036
|
+
const matchValue_19 = FSharpMap__TryFind(fields_10, fieldName);
|
|
4037
|
+
if (matchValue_19 == null) {
|
|
4048
4038
|
throw new TypeException(new TypeError$(toText(printf("Record field \'%s\' not found"))(fieldName), span_19));
|
|
4049
4039
|
}
|
|
4050
4040
|
else {
|
|
4051
|
-
return [s1_16,
|
|
4041
|
+
return [s1_16, matchValue_19];
|
|
4052
4042
|
}
|
|
4053
4043
|
}
|
|
4054
4044
|
default:
|
|
@@ -4057,8 +4047,8 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
|
4057
4047
|
}
|
|
4058
4048
|
case 3: {
|
|
4059
4049
|
const tField_6 = Types_freshVar();
|
|
4060
|
-
const s_12 = compose(unify(typeDefs,
|
|
4061
|
-
Compare: (
|
|
4050
|
+
const s_12 = compose(unify(typeDefs, matchValue_15, (matchValue_20 = Types_freshVar(), (matchValue_20.tag === 17) ? (new Type_1(/* TRecordShape */ 20, [matchValue_20.fields[0], ofList(singleton([fieldName, tField_6]), {
|
|
4051
|
+
Compare: (x_10, y_10) => (comparePrimitives(x_10, y_10) | 0),
|
|
4062
4052
|
}), false])) : (() => {
|
|
4063
4053
|
throw new Exception("Expected type variable");
|
|
4064
4054
|
})()), span_19), s1_16);
|
|
@@ -4069,24 +4059,24 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
|
4069
4059
|
}
|
|
4070
4060
|
};
|
|
4071
4061
|
const qualifiedTarget = (_arg_11) => {
|
|
4072
|
-
let matchResult_6,
|
|
4062
|
+
let matchResult_6, name_26, name_27, parent_1;
|
|
4073
4063
|
switch (_arg_11.tag) {
|
|
4074
4064
|
case 2: {
|
|
4075
4065
|
if (_arg_11.fields[0] === "Env") {
|
|
4076
4066
|
if (fieldName === "setExitCode") {
|
|
4077
4067
|
matchResult_6 = 0;
|
|
4078
4068
|
}
|
|
4079
|
-
else if (!
|
|
4069
|
+
else if (!InferenceEnv__ContainsKey_Z721C83C5(env, _arg_11.fields[0])) {
|
|
4080
4070
|
matchResult_6 = 1;
|
|
4081
|
-
|
|
4071
|
+
name_26 = _arg_11.fields[0];
|
|
4082
4072
|
}
|
|
4083
4073
|
else {
|
|
4084
4074
|
matchResult_6 = 3;
|
|
4085
4075
|
}
|
|
4086
4076
|
}
|
|
4087
|
-
else if (!
|
|
4077
|
+
else if (!InferenceEnv__ContainsKey_Z721C83C5(env, _arg_11.fields[0])) {
|
|
4088
4078
|
matchResult_6 = 1;
|
|
4089
|
-
|
|
4079
|
+
name_26 = _arg_11.fields[0];
|
|
4090
4080
|
}
|
|
4091
4081
|
else {
|
|
4092
4082
|
matchResult_6 = 3;
|
|
@@ -4095,7 +4085,7 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
|
4095
4085
|
}
|
|
4096
4086
|
case 22: {
|
|
4097
4087
|
matchResult_6 = 2;
|
|
4098
|
-
|
|
4088
|
+
name_27 = _arg_11.fields[1];
|
|
4099
4089
|
parent_1 = _arg_11.fields[0];
|
|
4100
4090
|
break;
|
|
4101
4091
|
}
|
|
@@ -4106,11 +4096,11 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
|
4106
4096
|
case 0:
|
|
4107
4097
|
return "Env";
|
|
4108
4098
|
case 1:
|
|
4109
|
-
return
|
|
4099
|
+
return name_26;
|
|
4110
4100
|
case 2: {
|
|
4111
|
-
const
|
|
4112
|
-
if (
|
|
4113
|
-
return (
|
|
4101
|
+
const option_9 = qualifiedTarget(parent_1);
|
|
4102
|
+
if (option_9 != null) {
|
|
4103
|
+
return (option_9 + ".") + name_27;
|
|
4114
4104
|
}
|
|
4115
4105
|
else {
|
|
4116
4106
|
return undefined;
|
|
@@ -4120,35 +4110,37 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
|
4120
4110
|
return undefined;
|
|
4121
4111
|
}
|
|
4122
4112
|
};
|
|
4123
|
-
const
|
|
4124
|
-
if (
|
|
4125
|
-
const
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
const
|
|
4129
|
-
const
|
|
4130
|
-
|
|
4113
|
+
const matchValue_21 = qualifiedTarget(target_1);
|
|
4114
|
+
if (matchValue_21 != null) {
|
|
4115
|
+
const qualifiedName = concat(matchValue_21, ".", fieldName);
|
|
4116
|
+
const matchValue_22 = InferenceEnv__TryFind_Z721C83C5(env, qualifiedName);
|
|
4117
|
+
if (matchValue_22 == null) {
|
|
4118
|
+
const patternInput_43 = inferExpr(telemetry, typeDefs, constructors, scope, env, target_1);
|
|
4119
|
+
const patternInput_44 = inferRecordField(patternInput_43[0], patternInput_43[1]);
|
|
4120
|
+
const tField_7 = patternInput_44[1];
|
|
4121
|
+
return [patternInput_44[0], tField_7, asTyped(telemetry, expr, tField_7)];
|
|
4131
4122
|
}
|
|
4132
4123
|
else {
|
|
4133
|
-
const
|
|
4134
|
-
|
|
4124
|
+
const patternInput_42 = instantiateValue(env, qualifiedName, matchValue_22);
|
|
4125
|
+
const t_9 = patternInput_42[0];
|
|
4126
|
+
return [emptySubst, t_9, withOpaqueEffect(patternInput_42[1], asTyped(telemetry, expr, t_9))];
|
|
4135
4127
|
}
|
|
4136
4128
|
}
|
|
4137
4129
|
else {
|
|
4138
|
-
const
|
|
4139
|
-
const
|
|
4140
|
-
const tField_8 =
|
|
4141
|
-
return [
|
|
4130
|
+
const patternInput_45 = inferExpr(telemetry, typeDefs, constructors, scope, env, target_1);
|
|
4131
|
+
const patternInput_46 = inferRecordField(patternInput_45[0], patternInput_45[1]);
|
|
4132
|
+
const tField_8 = patternInput_46[1];
|
|
4133
|
+
return [patternInput_46[0], tField_8, asTyped(telemetry, expr, tField_8)];
|
|
4142
4134
|
}
|
|
4143
4135
|
}
|
|
4144
4136
|
case 23: {
|
|
4145
4137
|
const span_20 = expr.fields[2];
|
|
4146
|
-
const
|
|
4147
|
-
const s1_19 =
|
|
4148
|
-
const
|
|
4149
|
-
const s2_10 =
|
|
4150
|
-
const targetType = applyType(s2_10,
|
|
4151
|
-
const keyType_1 = applyType(s2_10,
|
|
4138
|
+
const patternInput_47 = inferExpr(telemetry, typeDefs, constructors, scope, env, expr.fields[0]);
|
|
4139
|
+
const s1_19 = patternInput_47[0];
|
|
4140
|
+
const patternInput_48 = inferExpr(telemetry, typeDefs, constructors, scope, applyEnv(s1_19, env), expr.fields[1]);
|
|
4141
|
+
const s2_10 = patternInput_48[0];
|
|
4142
|
+
const targetType = applyType(s2_10, patternInput_47[1]);
|
|
4143
|
+
const keyType_1 = applyType(s2_10, patternInput_48[1]);
|
|
4152
4144
|
let matchResult_7, itemType_1, mapKeyType, valueType_1;
|
|
4153
4145
|
switch (targetType.tag) {
|
|
4154
4146
|
case 5: {
|
|
@@ -4224,111 +4216,111 @@ function inferExprRaw(telemetry, typeDefs, constructors, scope, env, expr) {
|
|
|
4224
4216
|
const a = expr.fields[1];
|
|
4225
4217
|
switch (op) {
|
|
4226
4218
|
case "|>": {
|
|
4227
|
-
const
|
|
4228
|
-
const tLeft =
|
|
4229
|
-
const s1_20 =
|
|
4230
|
-
const
|
|
4231
|
-
const s2_11 =
|
|
4219
|
+
const patternInput_49 = inferExpr(telemetry, typeDefs, constructors, scope, env, a);
|
|
4220
|
+
const tLeft = patternInput_49[1];
|
|
4221
|
+
const s1_20 = patternInput_49[0];
|
|
4222
|
+
const patternInput_50 = inferExpr(telemetry, typeDefs, constructors, scope, applyEnv(s1_20, env), b);
|
|
4223
|
+
const s2_11 = patternInput_50[0];
|
|
4232
4224
|
const tv_7 = Types_freshVar();
|
|
4233
|
-
const combined_1 = compose(unify(typeDefs, applyType(s2_11,
|
|
4225
|
+
const combined_1 = compose(unify(typeDefs, applyType(s2_11, patternInput_50[1]), new Type_1(/* TFun */ 11, [applyType(s2_11, tLeft), tv_7]), span_21), compose(s2_11, s1_20));
|
|
4234
4226
|
const s_17 = compose(constrainMapKeyTypes(typeDefs, span_21, applyType(combined_1, new Type_1(/* TFun */ 11, [tLeft, tv_7]))), combined_1);
|
|
4235
4227
|
const tRes_16 = applyType(s_17, tv_7);
|
|
4236
4228
|
return [s_17, tRes_16, asTyped(telemetry, expr, tRes_16)];
|
|
4237
4229
|
}
|
|
4238
4230
|
case "::": {
|
|
4239
|
-
const
|
|
4240
|
-
const tHead =
|
|
4241
|
-
const s1_21 =
|
|
4242
|
-
const
|
|
4243
|
-
const s2_12 =
|
|
4244
|
-
const s_18 = compose(unify(typeDefs, applyType(s2_12,
|
|
4231
|
+
const patternInput_51 = inferExpr(telemetry, typeDefs, constructors, scope, env, a);
|
|
4232
|
+
const tHead = patternInput_51[1];
|
|
4233
|
+
const s1_21 = patternInput_51[0];
|
|
4234
|
+
const patternInput_52 = inferExpr(telemetry, typeDefs, constructors, scope, applyEnv(s1_21, env), b);
|
|
4235
|
+
const s2_12 = patternInput_52[0];
|
|
4236
|
+
const s_18 = compose(unify(typeDefs, applyType(s2_12, patternInput_52[1]), new Type_1(/* TList */ 5, [tHead]), span_21), compose(s2_12, s1_21));
|
|
4245
4237
|
const tRes_17 = applyType(s_18, new Type_1(/* TList */ 5, [tHead]));
|
|
4246
4238
|
return [s_18, tRes_17, asTyped(telemetry, expr, tRes_17)];
|
|
4247
4239
|
}
|
|
4248
4240
|
case "@": {
|
|
4249
|
-
const
|
|
4250
|
-
const s1_22 =
|
|
4251
|
-
const
|
|
4252
|
-
const s2_13 =
|
|
4241
|
+
const patternInput_53 = inferExpr(telemetry, typeDefs, constructors, scope, env, a);
|
|
4242
|
+
const s1_22 = patternInput_53[0];
|
|
4243
|
+
const patternInput_54 = inferExpr(telemetry, typeDefs, constructors, scope, applyEnv(s1_22, env), b);
|
|
4244
|
+
const s2_13 = patternInput_54[0];
|
|
4253
4245
|
const tv_8 = Types_freshVar();
|
|
4254
|
-
const s3_10 = unify(typeDefs, applyType(s2_13,
|
|
4255
|
-
const s_19 = compose(unify(typeDefs, applyType(s3_10, applyType(s2_13,
|
|
4246
|
+
const s3_10 = unify(typeDefs, applyType(s2_13, patternInput_53[1]), new Type_1(/* TList */ 5, [tv_8]), span_21);
|
|
4247
|
+
const s_19 = compose(unify(typeDefs, applyType(s3_10, applyType(s2_13, patternInput_54[1])), new Type_1(/* TList */ 5, [applyType(s3_10, tv_8)]), span_21), compose(s3_10, compose(s2_13, s1_22)));
|
|
4256
4248
|
const tRes_18 = new Type_1(/* TList */ 5, [applyType(s_19, tv_8)]);
|
|
4257
4249
|
return [s_19, tRes_18, asTyped(telemetry, expr, tRes_18)];
|
|
4258
4250
|
}
|
|
4259
4251
|
default: {
|
|
4260
|
-
const
|
|
4261
|
-
const s1_23 =
|
|
4262
|
-
const
|
|
4263
|
-
const t2_3 =
|
|
4264
|
-
const s2_14 =
|
|
4265
|
-
const s3_11 = unify(typeDefs, applyType(s2_14,
|
|
4252
|
+
const patternInput_55 = inferExpr(telemetry, typeDefs, constructors, scope, env, a);
|
|
4253
|
+
const s1_23 = patternInput_55[0];
|
|
4254
|
+
const patternInput_56 = inferExpr(telemetry, typeDefs, constructors, scope, applyEnv(s1_23, env), b);
|
|
4255
|
+
const t2_3 = patternInput_56[1];
|
|
4256
|
+
const s2_14 = patternInput_56[0];
|
|
4257
|
+
const s3_11 = unify(typeDefs, applyType(s2_14, patternInput_55[1]), t2_3, span_21);
|
|
4266
4258
|
const t_10 = applyType(s3_11, t2_3);
|
|
4267
|
-
let
|
|
4259
|
+
let patternInput_58;
|
|
4268
4260
|
switch (op) {
|
|
4269
4261
|
case "+":
|
|
4270
4262
|
case "-":
|
|
4271
4263
|
case "*":
|
|
4272
4264
|
case "/": {
|
|
4273
|
-
|
|
4265
|
+
patternInput_58 = constrainNumeric(typeDefs, t_10, span_21);
|
|
4274
4266
|
break;
|
|
4275
4267
|
}
|
|
4276
4268
|
case "%": {
|
|
4277
|
-
|
|
4269
|
+
patternInput_58 = [unify(typeDefs, t_10, Type_1.TInt, span_21), Type_1.TInt];
|
|
4278
4270
|
break;
|
|
4279
4271
|
}
|
|
4280
4272
|
case "=": {
|
|
4281
|
-
|
|
4273
|
+
patternInput_58 = [emptySubst, Type_1.TBool];
|
|
4282
4274
|
break;
|
|
4283
4275
|
}
|
|
4284
4276
|
case "<":
|
|
4285
4277
|
case ">":
|
|
4286
4278
|
case "<=":
|
|
4287
4279
|
case ">=": {
|
|
4288
|
-
|
|
4280
|
+
patternInput_58 = [constrainNumeric(typeDefs, t_10, span_21)[0], Type_1.TBool];
|
|
4289
4281
|
break;
|
|
4290
4282
|
}
|
|
4291
4283
|
case "&&":
|
|
4292
4284
|
case "||": {
|
|
4293
|
-
|
|
4285
|
+
patternInput_58 = [unify(typeDefs, t_10, Type_1.TBool, span_21), Type_1.TBool];
|
|
4294
4286
|
break;
|
|
4295
4287
|
}
|
|
4296
4288
|
default:
|
|
4297
4289
|
throw new TypeException(new TypeError$(toText(printf("Unknown operator %s"))(op), span_21));
|
|
4298
4290
|
}
|
|
4299
|
-
const resultType =
|
|
4300
|
-
return [compose(
|
|
4291
|
+
const resultType = patternInput_58[1];
|
|
4292
|
+
return [compose(patternInput_58[0], compose(s3_11, compose(s2_14, s1_23))), resultType, asTyped(telemetry, expr, resultType)];
|
|
4301
4293
|
}
|
|
4302
4294
|
}
|
|
4303
4295
|
}
|
|
4304
4296
|
case 27: {
|
|
4305
|
-
const
|
|
4306
|
-
const t1_11 =
|
|
4307
|
-
return [
|
|
4297
|
+
const patternInput_59 = inferExpr(telemetry, typeDefs, constructors, scope, env, expr.fields[0]);
|
|
4298
|
+
const t1_11 = patternInput_59[1];
|
|
4299
|
+
return [patternInput_59[0], new Type_1(/* TOption */ 10, [t1_11]), asTyped(telemetry, expr, new Type_1(/* TOption */ 10, [t1_11]))];
|
|
4308
4300
|
}
|
|
4309
4301
|
case 28: {
|
|
4310
4302
|
const tv_9 = Types_freshVar();
|
|
4311
4303
|
return [emptySubst, new Type_1(/* TOption */ 10, [tv_9]), asTyped(telemetry, expr, new Type_1(/* TOption */ 10, [tv_9]))];
|
|
4312
4304
|
}
|
|
4313
4305
|
case 24: {
|
|
4314
|
-
const
|
|
4315
|
-
const t1_12 =
|
|
4316
|
-
const s1_25 =
|
|
4317
|
-
const
|
|
4318
|
-
const s2_15 =
|
|
4319
|
-
const s_21 = compose(unify(typeDefs, applyType(s2_15,
|
|
4306
|
+
const patternInput_60 = inferExpr(telemetry, typeDefs, constructors, scope, env, expr.fields[0]);
|
|
4307
|
+
const t1_12 = patternInput_60[1];
|
|
4308
|
+
const s1_25 = patternInput_60[0];
|
|
4309
|
+
const patternInput_61 = inferExpr(telemetry, typeDefs, constructors, scope, applyEnv(s1_25, env), expr.fields[1]);
|
|
4310
|
+
const s2_15 = patternInput_61[0];
|
|
4311
|
+
const s_21 = compose(unify(typeDefs, applyType(s2_15, patternInput_61[1]), new Type_1(/* TList */ 5, [t1_12]), expr.fields[2]), compose(s2_15, s1_25));
|
|
4320
4312
|
const tRes_19 = applyType(s_21, new Type_1(/* TList */ 5, [t1_12]));
|
|
4321
4313
|
return [s_21, tRes_19, asTyped(telemetry, expr, tRes_19)];
|
|
4322
4314
|
}
|
|
4323
4315
|
case 25: {
|
|
4324
4316
|
const span_23 = expr.fields[2];
|
|
4325
|
-
const
|
|
4326
|
-
const s1_26 =
|
|
4327
|
-
const
|
|
4328
|
-
const s2_16 =
|
|
4317
|
+
const patternInput_62 = inferExpr(telemetry, typeDefs, constructors, scope, env, expr.fields[0]);
|
|
4318
|
+
const s1_26 = patternInput_62[0];
|
|
4319
|
+
const patternInput_63 = inferExpr(telemetry, typeDefs, constructors, scope, applyEnv(s1_26, env), expr.fields[1]);
|
|
4320
|
+
const s2_16 = patternInput_63[0];
|
|
4329
4321
|
const tv_10 = Types_freshVar();
|
|
4330
|
-
const s3_13 = unify(typeDefs, applyType(s2_16,
|
|
4331
|
-
const s_22 = compose(unify(typeDefs, applyType(s3_13, applyType(s2_16,
|
|
4322
|
+
const s3_13 = unify(typeDefs, applyType(s2_16, patternInput_62[1]), new Type_1(/* TList */ 5, [tv_10]), span_23);
|
|
4323
|
+
const s_22 = compose(unify(typeDefs, applyType(s3_13, applyType(s2_16, patternInput_63[1])), new Type_1(/* TList */ 5, [applyType(s3_13, tv_10)]), span_23), compose(s3_13, compose(s2_16, s1_26)));
|
|
4332
4324
|
const tRes_20 = new Type_1(/* TList */ 5, [applyType(s_22, tv_10)]);
|
|
4333
4325
|
return [s_22, tRes_20, asTyped(telemetry, expr, tRes_20)];
|
|
4334
4326
|
}
|
|
@@ -4488,10 +4480,20 @@ function inferProgramWithExternsRawAndLocals(captureTelemetry, registration, pro
|
|
|
4488
4480
|
const signature = tupledArg_2[1];
|
|
4489
4481
|
return [tupledArg_2[0], new Scheme(signature.Parameters, defaultArg((option_1 = signature.Payload, (option_1 != null) ? (new Type_1(/* TFun */ 11, [option_1, signature.Result])) : undefined), signature.Result))];
|
|
4490
4482
|
}, toList(constructors));
|
|
4491
|
-
let env = fold((acc_1, tupledArg_3) => FSharpMap__Add(acc_1, tupledArg_3[0], tupledArg_3[1]), envFromExterns(registration.Functions), constructorSchemes)
|
|
4483
|
+
let env = new InferenceEnv(fold((acc_1, tupledArg_3) => FSharpMap__Add(acc_1, tupledArg_3[0], tupledArg_3[1]), envFromExterns(registration.Functions), constructorSchemes), ofList(choose((tupledArg_4) => {
|
|
4484
|
+
const option_4 = tupledArg_4[1].Payload;
|
|
4485
|
+
if (option_4 != null) {
|
|
4486
|
+
return [tupledArg_4[0], new OpaqueEffect(noOpaque.Live, noOpaque.Latent, 0)];
|
|
4487
|
+
}
|
|
4488
|
+
else {
|
|
4489
|
+
return undefined;
|
|
4490
|
+
}
|
|
4491
|
+
}, toList(constructors)), {
|
|
4492
|
+
Compare: (x_2, y_2) => (comparePrimitives(x_2, y_2) | 0),
|
|
4493
|
+
}), []);
|
|
4492
4494
|
const telemetry = captureTelemetry ? createTelemetry() : undefined;
|
|
4493
4495
|
const typed = [];
|
|
4494
|
-
let weakVariables = Types_ftvEnv(env);
|
|
4496
|
+
let weakVariables = Types_ftvEnv(env.Schemes);
|
|
4495
4497
|
let laterSubstitutions = emptySubst;
|
|
4496
4498
|
const remember = (scheme_1) => {
|
|
4497
4499
|
weakVariables = union(weakVariables, Types_ftvScheme(scheme_1));
|
|
@@ -4506,7 +4508,7 @@ function inferProgramWithExternsRawAndLocals(captureTelemetry, registration, pro
|
|
|
4506
4508
|
return undefined;
|
|
4507
4509
|
}
|
|
4508
4510
|
}, weakVariables), {
|
|
4509
|
-
Compare: (
|
|
4511
|
+
Compare: (x_3, y_3) => (comparePrimitives(x_3, y_3) | 0),
|
|
4510
4512
|
});
|
|
4511
4513
|
if (!FSharpMap__get_IsEmpty(relevant)) {
|
|
4512
4514
|
weakVariables = fold_1((variables, id_1, typ_2) => union(remove_1(id_1, variables), Types_ftvType(typ_2)), weakVariables, relevant);
|
|
@@ -4540,11 +4542,11 @@ function inferProgramWithExternsRawAndLocals(captureTelemetry, registration, pro
|
|
|
4540
4542
|
}
|
|
4541
4543
|
case 5: {
|
|
4542
4544
|
const span_2 = stmt.fields[3];
|
|
4543
|
-
const
|
|
4545
|
+
const name_3 = stmt.fields[0];
|
|
4544
4546
|
const importedType = annotationTypeFromRef(typeDefs, span_2, stmt.fields[1]);
|
|
4545
4547
|
if (importedType.tag === 11) {
|
|
4546
|
-
env =
|
|
4547
|
-
void (typed.push(new TypedStmt(/* TSBackendImport */ 4, [
|
|
4548
|
+
env = InferenceEnv__Add_Z72D39050(env, name_3, remember(new Scheme(empty_2(), importedType)));
|
|
4549
|
+
void (typed.push(new TypedStmt(/* TSBackendImport */ 4, [name_3, importedType, stmt.fields[2], span_2])));
|
|
4548
4550
|
}
|
|
4549
4551
|
else {
|
|
4550
4552
|
throw new TypeException(new TypeError$("Backend imports require a complete function signature", span_2));
|
|
@@ -4553,7 +4555,7 @@ function inferProgramWithExternsRawAndLocals(captureTelemetry, registration, pro
|
|
|
4553
4555
|
}
|
|
4554
4556
|
case 2: {
|
|
4555
4557
|
const span_3 = stmt.fields[6];
|
|
4556
|
-
const
|
|
4558
|
+
const name_4 = stmt.fields[0];
|
|
4557
4559
|
const isExported = stmt.fields[5];
|
|
4558
4560
|
const args = stmt.fields[1];
|
|
4559
4561
|
const patternInput_2 = bindingScope(scope, stmt.fields[2]);
|
|
@@ -4571,7 +4573,8 @@ function inferProgramWithExternsRawAndLocals(captureTelemetry, registration, pro
|
|
|
4571
4573
|
}
|
|
4572
4574
|
if (stmt.fields[4]) {
|
|
4573
4575
|
const tv = Types_freshVar();
|
|
4574
|
-
const patternInput_3 = inferExpr(telemetry, typeDefs, constructors, valueScope,
|
|
4576
|
+
const patternInput_3 = inferExpr(telemetry, typeDefs, constructors, valueScope, InferenceEnv__Add_Z72D39050(env, name_4, new Scheme(empty_2(), tv)), exprVal);
|
|
4577
|
+
const valueInfo = patternInput_3[2];
|
|
4575
4578
|
const t1 = patternInput_3[1];
|
|
4576
4579
|
const s1 = patternInput_3[0];
|
|
4577
4580
|
const s2 = unify(typeDefs, applyType(s1, tv), t1, span_3);
|
|
@@ -4582,12 +4585,13 @@ function inferProgramWithExternsRawAndLocals(captureTelemetry, registration, pro
|
|
|
4582
4585
|
const env$0027 = applyEnv(s, env);
|
|
4583
4586
|
const inferred = applyType(s, t1);
|
|
4584
4587
|
validateMapKeyTypes(typeDefs, span_3, inferred);
|
|
4585
|
-
const scheme_2 =
|
|
4586
|
-
env =
|
|
4587
|
-
void (typed.push(new TypedStmt(/* TSLet */ 1, [
|
|
4588
|
+
const scheme_2 = generalizeValue(typeDefs, applyOpaqueEffect(s, effectOf(valueInfo)), (typ_3) => generalizeBinding(scope, env$0027.Schemes, s, explicitParameters, typ_3, span_3), inferred);
|
|
4589
|
+
env = InferenceEnv__AddValue_Z1D943954(env$0027, name_4, remember(scheme_2), applyOpaqueEffect(s, effectOf(valueInfo)));
|
|
4590
|
+
void (typed.push(new TypedStmt(/* TSLet */ 1, [name_4, exprVal, inferred, true, isExported, span_3])));
|
|
4588
4591
|
}
|
|
4589
4592
|
else {
|
|
4590
4593
|
const patternInput_4 = inferExpr(telemetry, typeDefs, constructors, valueScope, env, exprVal);
|
|
4594
|
+
const valueInfo_1 = patternInput_4[2];
|
|
4591
4595
|
const t1_1 = patternInput_4[1];
|
|
4592
4596
|
const s1_1 = patternInput_4[0];
|
|
4593
4597
|
const s_1 = compose((returnAnnotation_1 == null) ? emptySubst : ((expectedReturn_1 = scopedAnnotation(valueScope, typeDefs, span_3, returnAnnotation_1), unify(typeDefs, functionReturnType(length(args), applyType(s1_1, t1_1)), expectedReturn_1, span_3))), s1_1);
|
|
@@ -4597,9 +4601,9 @@ function inferProgramWithExternsRawAndLocals(captureTelemetry, registration, pro
|
|
|
4597
4601
|
const env$0027_1 = applyEnv(s_1, env);
|
|
4598
4602
|
const inferred_1 = applyType(s_1, t1_1);
|
|
4599
4603
|
validateMapKeyTypes(typeDefs, span_3, inferred_1);
|
|
4600
|
-
const scheme_3 =
|
|
4601
|
-
env =
|
|
4602
|
-
void (typed.push(new TypedStmt(/* TSLet */ 1, [
|
|
4604
|
+
const scheme_3 = generalizeValue(typeDefs, applyOpaqueEffect(s_1, effectOf(valueInfo_1)), (typ_4) => generalizeBinding(scope, env$0027_1.Schemes, s_1, explicitParameters, typ_4, span_3), inferred_1);
|
|
4605
|
+
env = InferenceEnv__AddValue_Z1D943954(env$0027_1, name_4, remember(scheme_3), applyOpaqueEffect(s_1, effectOf(valueInfo_1)));
|
|
4606
|
+
void (typed.push(new TypedStmt(/* TSLet */ 1, [name_4, exprVal, inferred_1, false, isExported, span_3])));
|
|
4603
4607
|
}
|
|
4604
4608
|
break;
|
|
4605
4609
|
}
|
|
@@ -4616,6 +4620,7 @@ function inferProgramWithExternsRawAndLocals(captureTelemetry, registration, pro
|
|
|
4616
4620
|
startIndex_1 = t_2.LocalVariableTypes.length;
|
|
4617
4621
|
}
|
|
4618
4622
|
const patternInput_5 = inferExpr(telemetry, typeDefs, constructors, scope, env, expr_1);
|
|
4623
|
+
const valueInfo_2 = patternInput_5[2];
|
|
4619
4624
|
const s1_2 = patternInput_5[0];
|
|
4620
4625
|
const patternInput_6 = inferPattern(telemetry, typeDefs, constructors, pattern);
|
|
4621
4626
|
const s_2 = compose(unify(typeDefs, applyType(s1_2, patternInput_5[1]), patternInput_6[1], span_4), s1_2);
|
|
@@ -4623,11 +4628,11 @@ function inferProgramWithExternsRawAndLocals(captureTelemetry, registration, pro
|
|
|
4623
4628
|
applySubstToCapturedExpressions(telemetry, expressionStartIndex, s_2);
|
|
4624
4629
|
retainSubstitution(s_2);
|
|
4625
4630
|
const envBase = applyEnv(s_2, env);
|
|
4626
|
-
const typedBindings = map((
|
|
4627
|
-
iterate_2((
|
|
4631
|
+
const typedBindings = map((_arg_3, ty) => applyType(s_2, ty), patternInput_6[0]);
|
|
4632
|
+
iterate_2((_arg_4, ty_1) => {
|
|
4628
4633
|
validateMapKeyTypes(typeDefs, span_4, ty_1);
|
|
4629
4634
|
}, typedBindings);
|
|
4630
|
-
env = fold_1((state_1,
|
|
4635
|
+
env = fold_1((state_1, name_5, bindingType) => InferenceEnv__AddValue_Z1D943954(state_1, name_5, remember(generalizeValue(typeDefs, applyOpaqueEffect(s_2, effectOf(valueInfo_2)), (t_3) => Types_generalize(envBase.Schemes, t_3), bindingType)), applyOpaqueEffect(s_2, effectOf(valueInfo_2))), envBase, typedBindings);
|
|
4631
4636
|
void (typed.push(new TypedStmt(/* TSLetPattern */ 2, [pattern, expr_1, typedBindings, stmt.fields[2], span_4])));
|
|
4632
4637
|
break;
|
|
4633
4638
|
}
|
|
@@ -4641,26 +4646,28 @@ function inferProgramWithExternsRawAndLocals(captureTelemetry, registration, pro
|
|
|
4641
4646
|
const t_4 = telemetry;
|
|
4642
4647
|
startIndex_2 = t_4.LocalVariableTypes.length;
|
|
4643
4648
|
}
|
|
4644
|
-
const foldedBindings = map_1((
|
|
4645
|
-
const args_1 =
|
|
4646
|
-
const bindingSpan =
|
|
4649
|
+
const foldedBindings = map_1((tupledArg_5) => {
|
|
4650
|
+
const args_1 = tupledArg_5[1];
|
|
4651
|
+
const bindingSpan = tupledArg_5[4];
|
|
4647
4652
|
if (isEmpty_1(args_1)) {
|
|
4648
4653
|
throw new TypeException(new TypeError$("\'let rec ... and ...\' requires function arguments for each binding", bindingSpan));
|
|
4649
4654
|
}
|
|
4650
|
-
const folded = foldBack((arg_1, acc_3) => (new Expr(/* ELambda */ 5, [arg_1, acc_3, bindingSpan])), args_1,
|
|
4651
|
-
return [
|
|
4655
|
+
const folded = foldBack((arg_1, acc_3) => (new Expr(/* ELambda */ 5, [arg_1, acc_3, bindingSpan])), args_1, tupledArg_5[3]);
|
|
4656
|
+
return [tupledArg_5[0], bindingScope(scope, tupledArg_5[2]), folded, length(args_1), bindingSpan];
|
|
4652
4657
|
}, stmt.fields[0]);
|
|
4653
|
-
const freshByName = ofList(map_1((
|
|
4654
|
-
Compare: (
|
|
4658
|
+
const freshByName = ofList(map_1((tupledArg_6) => [tupledArg_6[0], Types_freshVar()], foldedBindings), {
|
|
4659
|
+
Compare: (x_4, y_4) => (comparePrimitives(x_4, y_4) | 0),
|
|
4655
4660
|
});
|
|
4656
|
-
const envRec_1 = fold_1((acc_4,
|
|
4661
|
+
const envRec_1 = fold_1((acc_4, name_8, tv_1) => InferenceEnv__Add_Z72D39050(acc_4, name_8, new Scheme(empty_2(), tv_1)), env, freshByName);
|
|
4657
4662
|
let sRec = emptySubst;
|
|
4663
|
+
const groupEffects = [];
|
|
4658
4664
|
const enumerator_1 = getEnumerator(foldedBindings);
|
|
4659
4665
|
try {
|
|
4660
4666
|
while (enumerator_1["System.Collections.IEnumerator.MoveNext"]()) {
|
|
4661
4667
|
const forLoopVar_1 = enumerator_1["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
4662
4668
|
const patternInput_7 = inferExpr(telemetry, typeDefs, constructors, forLoopVar_1[1][0], applyEnv(sRec, envRec_1), forLoopVar_1[2]);
|
|
4663
4669
|
const s1_3 = patternInput_7[0];
|
|
4670
|
+
void (groupEffects.push(effectOf(patternInput_7[2])));
|
|
4664
4671
|
const s2_2 = unify(typeDefs, applyType(s1_3, applyType(sRec, FSharpMap__get_Item(freshByName, forLoopVar_1[0]))), patternInput_7[1], forLoopVar_1[4]);
|
|
4665
4672
|
sRec = compose(s2_2, compose(s1_3, sRec));
|
|
4666
4673
|
}
|
|
@@ -4690,17 +4697,20 @@ function inferProgramWithExternsRawAndLocals(captureTelemetry, registration, pro
|
|
|
4690
4697
|
applySubstToCapturedExpressions(telemetry, expressionStartIndex, sRec);
|
|
4691
4698
|
retainSubstitution(sRec);
|
|
4692
4699
|
const envGeneralize = applyEnv(sRec, env);
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4700
|
+
let groupEffect;
|
|
4701
|
+
const effect_6 = recursiveOpaqueEffects(groupEffects);
|
|
4702
|
+
groupEffect = applyOpaqueEffect(sRec, effect_6);
|
|
4703
|
+
const schemes = map_1((tupledArg_7) => {
|
|
4704
|
+
const name_11 = tupledArg_7[0];
|
|
4705
|
+
const inferred_2 = applyType(sRec, FSharpMap__get_Item(freshByName, name_11));
|
|
4696
4706
|
validateMapKeyTypes(typeDefs, span_5, inferred_2);
|
|
4697
|
-
return [
|
|
4707
|
+
return [name_11, generalizeValue(typeDefs, groupEffect, (typ_5) => generalizeBinding(scope, envGeneralize.Schemes, sRec, tupledArg_7[1][1], typ_5, tupledArg_7[4]), inferred_2)];
|
|
4698
4708
|
}, foldedBindings);
|
|
4699
|
-
const typedBindings_1 = map_1((
|
|
4700
|
-
const
|
|
4701
|
-
return [
|
|
4709
|
+
const typedBindings_1 = map_1((tupledArg_8) => {
|
|
4710
|
+
const name_12 = tupledArg_8[0];
|
|
4711
|
+
return [name_12, tupledArg_8[2], applyType(sRec, FSharpMap__get_Item(freshByName, name_12)), tupledArg_8[4]];
|
|
4702
4712
|
}, foldedBindings);
|
|
4703
|
-
env = fold((acc_5,
|
|
4713
|
+
env = fold((acc_5, tupledArg_9) => InferenceEnv__AddValue_Z1D943954(acc_5, tupledArg_9[0], remember(tupledArg_9[1]), groupEffect), envGeneralize, schemes);
|
|
4704
4714
|
void (typed.push(new TypedStmt(/* TSLetRecGroup */ 3, [typedBindings_1, stmt.fields[1], span_5])));
|
|
4705
4715
|
break;
|
|
4706
4716
|
}
|
|
@@ -4723,7 +4733,7 @@ function inferProgramWithExternsRawAndLocals(captureTelemetry, registration, pro
|
|
|
4723
4733
|
validateMapKeyTypes(typeDefs, Ast_spanOfExpr(expr_2), applyType(s_3, t1_3));
|
|
4724
4734
|
retainSubstitution(s_3);
|
|
4725
4735
|
env = applyEnv(s_3, env);
|
|
4726
|
-
void (typed.push(new TypedStmt(/* TSExpr */ 5, [patternInput_8[2]])));
|
|
4736
|
+
void (typed.push(new TypedStmt(/* TSExpr */ 5, [patternInput_8[2].Typed])));
|
|
4727
4737
|
break;
|
|
4728
4738
|
}
|
|
4729
4739
|
default:
|
|
@@ -4740,11 +4750,11 @@ function inferProgramWithExternsRawAndLocals(captureTelemetry, registration, pro
|
|
|
4740
4750
|
const resolve = (t_6) => applyType(laterSubstitutions, t_6);
|
|
4741
4751
|
for (let i_1 = 0; i_1 <= (typed.length - 1); i_1++) {
|
|
4742
4752
|
let matchValue_2, expr_6;
|
|
4743
|
-
setItem(typed, i_1, (matchValue_2 = item_22(i_1, typed), (matchValue_2.tag === 1) ? (new TypedStmt(/* TSLet */ 1, [matchValue_2.fields[0], matchValue_2.fields[1], resolve(matchValue_2.fields[2]), matchValue_2.fields[3], matchValue_2.fields[4], matchValue_2.fields[5]])) : ((matchValue_2.tag === 2) ? (new TypedStmt(/* TSLetPattern */ 2, [matchValue_2.fields[0], matchValue_2.fields[1], map(uncurry2((
|
|
4753
|
+
setItem(typed, i_1, (matchValue_2 = item_22(i_1, typed), (matchValue_2.tag === 1) ? (new TypedStmt(/* TSLet */ 1, [matchValue_2.fields[0], matchValue_2.fields[1], resolve(matchValue_2.fields[2]), matchValue_2.fields[3], matchValue_2.fields[4], matchValue_2.fields[5]])) : ((matchValue_2.tag === 2) ? (new TypedStmt(/* TSLetPattern */ 2, [matchValue_2.fields[0], matchValue_2.fields[1], map(uncurry2((_arg_14) => resolve), matchValue_2.fields[2]), matchValue_2.fields[3], matchValue_2.fields[4]])) : ((matchValue_2.tag === 3) ? (new TypedStmt(/* TSLetRecGroup */ 3, [map_1((tupledArg_10) => [tupledArg_10[0], tupledArg_10[1], resolve(tupledArg_10[2]), tupledArg_10[3]], matchValue_2.fields[0]), matchValue_2.fields[1], matchValue_2.fields[2]])) : ((matchValue_2.tag === 5) ? ((expr_6 = matchValue_2.fields[0], new TypedStmt(/* TSExpr */ 5, [new TypedExpr(expr_6.Expr, resolve(expr_6.Type), expr_6.Span)]))) : matchValue_2)))));
|
|
4744
4754
|
}
|
|
4745
4755
|
}
|
|
4746
|
-
const expressionTypes = (telemetry == null) ? empty_2() :
|
|
4747
|
-
return [
|
|
4756
|
+
const expressionTypes = (telemetry == null) ? empty_2() : toList_2(telemetry.ExpressionTypes);
|
|
4757
|
+
return [toList_2(typed), capturedLocalVariableTypes(telemetry), expressionTypes];
|
|
4748
4758
|
}
|
|
4749
4759
|
catch (matchValue_3) {
|
|
4750
4760
|
throw matchValue_3;
|
|
@@ -4756,11 +4766,11 @@ export function inferProgramWithExternsRaw(externs, program) {
|
|
|
4756
4766
|
}
|
|
4757
4767
|
|
|
4758
4768
|
function validateProgramBindings(externs, program) {
|
|
4759
|
-
const option_1 = tryFind_1((ext) =>
|
|
4769
|
+
const option_1 = tryFind_1((ext) => contains(ext.Name, builtinReservedNames), externs);
|
|
4760
4770
|
if (option_1 != null) {
|
|
4761
4771
|
throw new TypeException(new TypeError$(concat("Host extern \'", option_1.Name, "\' collides with reserved stdlib symbol"), unknownSpan));
|
|
4762
4772
|
}
|
|
4763
|
-
const option_3 = tryFind_1((name) =>
|
|
4773
|
+
const option_3 = tryFind_1((name) => contains(name, builtinReservedNames), topLevelBindingNames(program));
|
|
4764
4774
|
if (option_3 != null) {
|
|
4765
4775
|
throw new TypeException(new TypeError$(concat("Top-level binding \'", option_3, "\' collides with reserved stdlib symbol"), unknownSpan));
|
|
4766
4776
|
}
|
|
@@ -4940,7 +4950,7 @@ export function inferResolvedProgramWithRegistration(registration, program) {
|
|
|
4940
4950
|
default:
|
|
4941
4951
|
return _arg_1;
|
|
4942
4952
|
}
|
|
4943
|
-
}), new Scheme(
|
|
4953
|
+
}), new Scheme(toList_2(rangeDouble(0, 1, length(variables) - 1)), normalize(_arg.fields[1]))))))) : undefined));
|
|
4944
4954
|
void (symbols.push(symbol));
|
|
4945
4955
|
const key_2 = [kind, name_4, span];
|
|
4946
4956
|
if (!symbolsByLocation.has(key_2)) {
|
|
@@ -5597,7 +5607,7 @@ export function inferResolvedProgramWithRegistration(registration, program) {
|
|
|
5597
5607
|
finally {
|
|
5598
5608
|
disposeSafe(enumerator_12);
|
|
5599
5609
|
}
|
|
5600
|
-
const resolvedReferences =
|
|
5610
|
+
const resolvedReferences = toList_2(references);
|
|
5601
5611
|
const referenceOccurrences = new Dictionary([], {
|
|
5602
5612
|
Equals: equals,
|
|
5603
5613
|
GetHashCode: (x_11) => (safeHash(x_11) | 0),
|
|
@@ -6532,7 +6542,7 @@ export function inferResolvedProgramWithRegistration(registration, program) {
|
|
|
6532
6542
|
const name_55 = tupledArg_22[0];
|
|
6533
6543
|
const definition_11 = tupledArg_22[1];
|
|
6534
6544
|
return new ResolvedStatement(syntheticSpan, empty_2(), undefined, new ResolvedStatementNode(/* ResolvedTypeDeclaration */ 0, [new ResolvedTypeDeclaration(bindingAt(ResolvedSymbolKind.TypeSymbol, name_55, syntheticSpan, Types_applied(name_55, definition_11)), false, definition_11, (definition_11.tag === 8) ? toList(definition_11.fields[0]) : ((definition_11.tag === 19) ? toList(definition_11.fields[1]) : empty_2()), (definition_11.tag === 15) ? toList(definition_11.fields[1]) : empty_2(), undefined)]), empty_2(), empty_2());
|
|
6535
|
-
}, toList(hostDefinitions)), resolvedStatements), expressions,
|
|
6545
|
+
}, toList(hostDefinitions)), resolvedStatements), expressions, toList_2(symbols), resolvedReferences);
|
|
6536
6546
|
}
|
|
6537
6547
|
|
|
6538
6548
|
/**
|
|
@@ -6570,20 +6580,20 @@ export function inferProgram(program) {
|
|
|
6570
6580
|
}
|
|
6571
6581
|
|
|
6572
6582
|
export function inferProgramWithRegistration(registration, program) {
|
|
6573
|
-
if (exists((ext) =>
|
|
6583
|
+
if (exists((ext) => contains(ext.Name, builtinReservedNames), registration.Functions)) {
|
|
6574
6584
|
throw new TypeException(new TypeError$("Host extern collides with reserved stdlib symbol", unknownSpan));
|
|
6575
6585
|
}
|
|
6576
|
-
if (exists((name) =>
|
|
6586
|
+
if (exists((name) => contains(name, builtinReservedNames), topLevelBindingNames(program))) {
|
|
6577
6587
|
throw new TypeException(new TypeError$("Top-level binding collides with reserved stdlib symbol", unknownSpan));
|
|
6578
6588
|
}
|
|
6579
6589
|
return inferProgramWithExternsRawAndLocals(false, registration, program)[0];
|
|
6580
6590
|
}
|
|
6581
6591
|
|
|
6582
6592
|
export function inferProgramWithRegistrationAndTypes(registration, program) {
|
|
6583
|
-
if (exists((ext) =>
|
|
6593
|
+
if (exists((ext) => contains(ext.Name, builtinReservedNames), registration.Functions)) {
|
|
6584
6594
|
throw new TypeException(new TypeError$("Host extern collides with reserved stdlib symbol", unknownSpan));
|
|
6585
6595
|
}
|
|
6586
|
-
if (exists((name) =>
|
|
6596
|
+
if (exists((name) => contains(name, builtinReservedNames), topLevelBindingNames(program))) {
|
|
6587
6597
|
throw new TypeException(new TypeError$("Top-level binding collides with reserved stdlib symbol", unknownSpan));
|
|
6588
6598
|
}
|
|
6589
6599
|
return inferProgramWithExternsRawAndLocals(true, registration, program);
|