firefly-compiler 0.4.20 → 0.4.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiler/Builder.ff +23 -13
- package/compiler/Dictionaries.ff +10 -10
- package/compiler/Inference.ff +167 -148
- package/compiler/JsEmitter.ff +122 -78
- package/compiler/LspHook.ff +6 -3
- package/compiler/Main.ff +24 -10
- package/compiler/Patterns.ff +1 -1
- package/compiler/Resolver.ff +167 -159
- package/compiler/Substitution.ff +2 -2
- package/compiler/Syntax.ff +1 -0
- package/compiler/Unification.ff +1 -1
- package/core/Array.ff +6 -4
- package/core/Int.ff +12 -12
- package/core/List.ff +6 -4
- package/core/Map.ff +8 -0
- package/core/Set.ff +7 -0
- package/experimental/benchmarks/ListGrab.ff +23 -0
- package/experimental/benchmarks/ListGrab.java +55 -0
- package/experimental/benchmarks/Pyrotek45.ff +30 -0
- package/experimental/benchmarks/Pyrotek45.java +64 -0
- package/experimental/tests/TestJson.ff +26 -0
- package/lsp/Handler.ff +65 -61
- package/lsp/SignatureHelpHandler.ff +5 -4
- package/lsp/TestReferences.ff +15 -0
- package/lsp/TestReferencesCase.ff +8 -0
- package/output/js/ff/compiler/Builder.mjs +50 -44
- package/output/js/ff/compiler/Dependencies.mjs +0 -2
- package/output/js/ff/compiler/Deriver.mjs +16 -140
- package/output/js/ff/compiler/Dictionaries.mjs +24 -238
- package/output/js/ff/compiler/Environment.mjs +12 -154
- package/output/js/ff/compiler/Inference.mjs +207 -1069
- package/output/js/ff/compiler/JsEmitter.mjs +434 -2342
- package/output/js/ff/compiler/JsImporter.mjs +0 -12
- package/output/js/ff/compiler/LspHook.mjs +20 -446
- package/output/js/ff/compiler/Main.mjs +110 -553
- package/output/js/ff/compiler/Parser.mjs +36 -356
- package/output/js/ff/compiler/Patterns.mjs +24 -204
- package/output/js/ff/compiler/Resolver.mjs +428 -554
- package/output/js/ff/compiler/Substitution.mjs +6 -164
- package/output/js/ff/compiler/Syntax.mjs +449 -3293
- package/output/js/ff/compiler/Token.mjs +9 -1095
- package/output/js/ff/compiler/Tokenizer.mjs +4 -2
- package/output/js/ff/compiler/Unification.mjs +30 -364
- package/output/js/ff/compiler/Wildcards.mjs +0 -86
- package/output/js/ff/compiler/Workspace.mjs +8 -96
- package/output/js/ff/core/Array.mjs +15 -8
- package/output/js/ff/core/AssetSystem.mjs +4 -14
- package/output/js/ff/core/Bool.mjs +0 -12
- package/output/js/ff/core/Core.mjs +0 -30
- package/output/js/ff/core/Int.mjs +24 -24
- package/output/js/ff/core/IntMap.mjs +0 -8
- package/output/js/ff/core/Json.mjs +0 -40
- package/output/js/ff/core/List.mjs +23 -32
- package/output/js/ff/core/Lock.mjs +0 -10
- package/output/js/ff/core/Map.mjs +26 -24
- package/output/js/ff/core/Option.mjs +10 -286
- package/output/js/ff/core/Ordering.mjs +16 -158
- package/output/js/ff/core/Pair.mjs +2 -34
- package/output/js/ff/core/Path.mjs +2 -28
- package/output/js/ff/core/Random.mjs +4 -4
- package/output/js/ff/core/RbMap.mjs +56 -644
- package/output/js/ff/core/Set.mjs +16 -0
- package/output/js/ff/core/Show.mjs +0 -16
- package/output/js/ff/core/Stream.mjs +14 -144
- package/output/js/ff/core/StringMap.mjs +0 -8
- package/output/js/ff/core/Try.mjs +4 -108
- package/output/js/ff/core/Unit.mjs +2 -16
- package/package.json +1 -1
- package/postgresql/Pg.ff +23 -23
- package/vscode/package.json +1 -1
- package/bin/firefly.mjs +0 -2
- package/guide/Main.ff +0 -22
|
@@ -124,20 +124,14 @@ return ((("ff:core/" + name_) + ".") + name_)
|
|
|
124
124
|
export function constraintsToInstances_(constraints_) {
|
|
125
125
|
return ff_core_List.List_toMap(ff_core_List.List_map(constraints_, ((c_) => {
|
|
126
126
|
const typeName_ = (((_1) => {
|
|
127
|
-
{
|
|
128
127
|
if(_1.TConstructor) {
|
|
129
128
|
const name_ = _1.name_;
|
|
130
129
|
return name_
|
|
131
|
-
return
|
|
132
130
|
}
|
|
133
|
-
}
|
|
134
|
-
{
|
|
135
131
|
if(_1.TVariable) {
|
|
136
132
|
const at_ = _1.at_;
|
|
137
133
|
const i_ = _1.index_;
|
|
138
134
|
return ff_compiler_Inference.fail_(c_.at_, ("Unexpected unification variable: $" + i_))
|
|
139
|
-
return
|
|
140
|
-
}
|
|
141
135
|
}
|
|
142
136
|
}))(ff_core_List.List_grabFirst(c_.generics_));
|
|
143
137
|
return ff_core_Pair.Pair(ff_compiler_Unification.InstanceKey(c_.name_, typeName_), ff_compiler_Unification.InstanceValue([], [], ff_compiler_Syntax.PackagePair("", ""), "", c_.name_, c_.generics_))
|
|
@@ -159,20 +153,14 @@ return ((("ff:core/" + name_) + ".") + name_)
|
|
|
159
153
|
export async function constraintsToInstances_$(constraints_, $task) {
|
|
160
154
|
return ff_core_List.List_toMap(ff_core_List.List_map(constraints_, ((c_) => {
|
|
161
155
|
const typeName_ = (((_1) => {
|
|
162
|
-
{
|
|
163
156
|
if(_1.TConstructor) {
|
|
164
157
|
const name_ = _1.name_;
|
|
165
158
|
return name_
|
|
166
|
-
return
|
|
167
159
|
}
|
|
168
|
-
}
|
|
169
|
-
{
|
|
170
160
|
if(_1.TVariable) {
|
|
171
161
|
const at_ = _1.at_;
|
|
172
162
|
const i_ = _1.index_;
|
|
173
163
|
return ff_compiler_Inference.fail_(c_.at_, ("Unexpected unification variable: $" + i_))
|
|
174
|
-
return
|
|
175
|
-
}
|
|
176
164
|
}
|
|
177
165
|
}))(ff_core_List.List_grabFirst(c_.generics_));
|
|
178
166
|
return ff_core_Pair.Pair(ff_compiler_Unification.InstanceKey(c_.name_, typeName_), ff_compiler_Unification.InstanceValue([], [], ff_compiler_Syntax.PackagePair("", ""), "", c_.name_, c_.generics_))
|
|
@@ -209,7 +197,6 @@ const _1 = definition_;
|
|
|
209
197
|
{
|
|
210
198
|
const _c = _1;
|
|
211
199
|
return ff_compiler_Syntax.DTrait(_c.at_, _c.name_, _c.generics_, _c.constraints_, _c.generatorParameters_, _c.methods_, _c.methodDefaults_, _c.methodGenerators_)
|
|
212
|
-
return
|
|
213
200
|
}
|
|
214
201
|
}
|
|
215
202
|
}
|
|
@@ -257,7 +244,6 @@ const _1 = p_;
|
|
|
257
244
|
{
|
|
258
245
|
const _c = _1;
|
|
259
246
|
return ff_compiler_Syntax.Parameter(_c.at_, _c.mutable_, _c.name_, ff_compiler_Unification.Unification_instantiate(self_.unification_, instantiationMap_, p_.valueType_), _c.default_)
|
|
260
|
-
return
|
|
261
247
|
}
|
|
262
248
|
}
|
|
263
249
|
}));
|
|
@@ -298,7 +284,6 @@ const _1 = definition_;
|
|
|
298
284
|
{
|
|
299
285
|
const _c = _1;
|
|
300
286
|
return ff_compiler_Syntax.DLet(_c.at_, _c.name_, _c.variableType_, value_)
|
|
301
|
-
return
|
|
302
287
|
}
|
|
303
288
|
}
|
|
304
289
|
}
|
|
@@ -320,7 +305,6 @@ const _1 = case_;
|
|
|
320
305
|
{
|
|
321
306
|
const _c = _1;
|
|
322
307
|
return ff_compiler_Syntax.MatchCase(_c.at_, [ff_compiler_Syntax.PVariable(method_.at_, ff_core_Option.None()), ...case_.patterns_], _c.guards_, _c.body_)
|
|
323
|
-
return
|
|
324
308
|
}
|
|
325
309
|
}
|
|
326
310
|
})))
|
|
@@ -340,7 +324,6 @@ const _1 = definition_;
|
|
|
340
324
|
{
|
|
341
325
|
const _c = _1;
|
|
342
326
|
return ff_compiler_Syntax.DExtend(_c.at_, _c.name_, _c.generics_, _c.constraints_, _c.type_, functions_)
|
|
343
|
-
return
|
|
344
327
|
}
|
|
345
328
|
}
|
|
346
329
|
}
|
|
@@ -383,35 +366,25 @@ return
|
|
|
383
366
|
export function Inference_inferLambda(self_, environment_, expected_, lambda_) {
|
|
384
367
|
const unitName_ = ff_compiler_Inference.core_("Unit");
|
|
385
368
|
const returnsUnit_ = (((_1) => {
|
|
386
|
-
{
|
|
387
369
|
if(_1.TConstructor) {
|
|
388
370
|
const name_ = _1.name_;
|
|
389
371
|
const ts_ = _1.generics_;
|
|
390
|
-
|
|
391
|
-
if(_guard1) {
|
|
372
|
+
if(ff_core_String.String_startsWith(name_, "Function$", 0)) {
|
|
392
373
|
{
|
|
393
374
|
const _1 = ff_core_List.List_grabLast(ts_);
|
|
394
|
-
{
|
|
395
|
-
if(_1.TConstructor) {
|
|
375
|
+
if(_1.TConstructor && _1.generics_.length === 0) {
|
|
396
376
|
const n_ = _1.name_;
|
|
397
|
-
if(_1.generics_.length === 0) {
|
|
398
377
|
return (n_ === unitName_)
|
|
399
|
-
return
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
378
|
}
|
|
403
379
|
{
|
|
404
380
|
return false
|
|
405
|
-
return
|
|
406
381
|
}
|
|
407
382
|
}
|
|
408
383
|
return
|
|
409
384
|
}
|
|
410
385
|
}
|
|
411
|
-
}
|
|
412
386
|
{
|
|
413
387
|
return false
|
|
414
|
-
return
|
|
415
388
|
}
|
|
416
389
|
}))(ff_compiler_Unification.Unification_substitute(self_.unification_, expected_));
|
|
417
390
|
const cases_ = ((!returnsUnit_)
|
|
@@ -422,7 +395,6 @@ const _1 = c_;
|
|
|
422
395
|
{
|
|
423
396
|
const _c = _1;
|
|
424
397
|
return ff_compiler_Syntax.MatchCase(_c.at_, _c.patterns_, _c.guards_, ff_compiler_Syntax.ESequential(c_.at_, c_.body_, ff_compiler_Syntax.EVariant(c_.at_, unitName_, [], ff_core_Option.None())))
|
|
425
|
-
return
|
|
426
398
|
}
|
|
427
399
|
}
|
|
428
400
|
})));
|
|
@@ -460,7 +432,6 @@ const at_ = _2.first_;
|
|
|
460
432
|
const type_ = _2.second_;
|
|
461
433
|
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", []);
|
|
462
434
|
return ff_compiler_Environment.Scheme(true, false, false, false, ff_compiler_Syntax.Signature(at_, name_, false, [], [], [], type_, noEffect_))
|
|
463
|
-
return
|
|
464
435
|
}
|
|
465
436
|
}), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
466
437
|
{
|
|
@@ -468,7 +439,6 @@ const _1 = environment_;
|
|
|
468
439
|
{
|
|
469
440
|
const _c = _1;
|
|
470
441
|
return ff_compiler_Environment.Environment(_c.modulePrefix_, ff_core_Map.Map_addAll(environment1_.symbols_, symbols_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.imports_, _c.effect_, _c.selfVariable_)
|
|
471
|
-
return
|
|
472
442
|
}
|
|
473
443
|
}
|
|
474
444
|
return
|
|
@@ -485,7 +455,6 @@ const at_ = _2.first_;
|
|
|
485
455
|
const type_ = _2.second_;
|
|
486
456
|
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", []);
|
|
487
457
|
return ff_compiler_Environment.Scheme(true, false, false, false, ff_compiler_Syntax.Signature(at_, name_, false, [], [], [], type_, noEffect_))
|
|
488
|
-
return
|
|
489
458
|
}
|
|
490
459
|
}), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
491
460
|
ff_core_Array.Array_push(guards_, (((_c) => {
|
|
@@ -496,7 +465,6 @@ const _1 = environment2_;
|
|
|
496
465
|
{
|
|
497
466
|
const _c = _1;
|
|
498
467
|
return ff_compiler_Environment.Environment(_c.modulePrefix_, ff_core_Map.Map_addAll(environment2_.symbols_, symbols_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.imports_, _c.effect_, _c.selfVariable_)
|
|
499
|
-
return
|
|
500
468
|
}
|
|
501
469
|
}
|
|
502
470
|
}));
|
|
@@ -505,7 +473,6 @@ const _1 = case_;
|
|
|
505
473
|
{
|
|
506
474
|
const _c = _1;
|
|
507
475
|
return ff_compiler_Syntax.MatchCase(_c.at_, _c.patterns_, ff_core_Array.Array_drain(guards_), ff_compiler_Inference.Inference_inferTerm(self_, environment3_, returnType_, case_.body_))
|
|
508
|
-
return
|
|
509
476
|
}
|
|
510
477
|
}
|
|
511
478
|
}
|
|
@@ -513,24 +480,17 @@ return
|
|
|
513
480
|
export function Inference_inferPattern(self_, environment_, expected_, pattern_) {
|
|
514
481
|
if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
|
|
515
482
|
if((((_1) => {
|
|
516
|
-
{
|
|
517
483
|
if(_1.PVariantAs) {
|
|
518
484
|
const at_ = _1.at_;
|
|
519
485
|
const variableAt_ = _1.variableAt_;
|
|
520
486
|
return ((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, at_) || ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, variableAt_)) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, variableAt_))
|
|
521
|
-
return
|
|
522
487
|
}
|
|
523
|
-
}
|
|
524
|
-
{
|
|
525
488
|
if(_1.PAlias) {
|
|
526
489
|
const at_ = _1.at_;
|
|
527
490
|
return (ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, at_))
|
|
528
|
-
return
|
|
529
|
-
}
|
|
530
491
|
}
|
|
531
492
|
{
|
|
532
493
|
return ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, pattern_.at_)
|
|
533
|
-
return
|
|
534
494
|
}
|
|
535
495
|
}))(pattern_)) {
|
|
536
496
|
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.InferPatternHook(self_.unification_, environment_, expected_, pattern_))
|
|
@@ -542,53 +502,30 @@ return ff_core_Map.empty_()
|
|
|
542
502
|
}
|
|
543
503
|
{
|
|
544
504
|
const _1 = pattern_;
|
|
545
|
-
{
|
|
546
505
|
if(_1.PString) {
|
|
547
506
|
return literal_("String")
|
|
548
|
-
return
|
|
549
|
-
}
|
|
550
507
|
}
|
|
551
|
-
{
|
|
552
508
|
if(_1.PInt) {
|
|
553
509
|
return literal_("Int")
|
|
554
|
-
return
|
|
555
510
|
}
|
|
556
|
-
}
|
|
557
|
-
{
|
|
558
511
|
if(_1.PChar) {
|
|
559
512
|
return literal_("Char")
|
|
560
|
-
return
|
|
561
|
-
}
|
|
562
513
|
}
|
|
563
|
-
{
|
|
564
|
-
if(_1.PVariable) {
|
|
514
|
+
if(_1.PVariable && _1.name_.None) {
|
|
565
515
|
const at_ = _1.at_;
|
|
566
|
-
if(_1.name_.None) {
|
|
567
516
|
return ff_core_Map.empty_()
|
|
568
|
-
return
|
|
569
|
-
}
|
|
570
517
|
}
|
|
571
|
-
|
|
572
|
-
{
|
|
573
|
-
if(_1.PVariable) {
|
|
518
|
+
if(_1.PVariable && _1.name_.Some) {
|
|
574
519
|
const at_ = _1.at_;
|
|
575
|
-
if(_1.name_.Some) {
|
|
576
520
|
const name_ = _1.name_.value_;
|
|
577
521
|
return ff_core_List.List_toMap([ff_core_Pair.Pair(name_, ff_core_Pair.Pair(at_, expected_))], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
|
|
578
|
-
return
|
|
579
522
|
}
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
{
|
|
583
523
|
if(_1.PAlias) {
|
|
584
524
|
const at_ = _1.at_;
|
|
585
525
|
const pattern_ = _1.pattern_;
|
|
586
526
|
const variable_ = _1.variable_;
|
|
587
527
|
return ff_core_Map.Map_add(ff_compiler_Inference.Inference_inferPattern(self_, environment_, expected_, pattern_), variable_, ff_core_Pair.Pair(at_, expected_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
|
|
588
|
-
return
|
|
589
528
|
}
|
|
590
|
-
}
|
|
591
|
-
{
|
|
592
529
|
if(_1.PVariantAs) {
|
|
593
530
|
const at_ = _1.at_;
|
|
594
531
|
const name_ = _1.name_;
|
|
@@ -614,44 +551,24 @@ return ff_core_Pair.Pair(_w1, ff_core_Pair.Pair(variableAt_, recordType_))
|
|
|
614
551
|
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
|
|
615
552
|
return
|
|
616
553
|
}
|
|
617
|
-
|
|
618
|
-
{
|
|
619
|
-
if(_1.PVariant) {
|
|
554
|
+
if(_1.PVariant && _1.name_ === "List$Empty" && _1.patterns_.length === 0) {
|
|
620
555
|
const at_ = _1.at_;
|
|
621
|
-
if(_1.name_ === "List$Empty") {
|
|
622
|
-
if(_1.patterns_.length === 0) {
|
|
623
556
|
const itemType_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, at_);
|
|
624
557
|
const listType_ = ff_compiler_Syntax.TConstructor(at_, ff_compiler_Inference.core_("List"), [itemType_]);
|
|
625
558
|
ff_compiler_Unification.Unification_unify(self_.unification_, at_, expected_, listType_);
|
|
626
559
|
return ff_core_List.List_toMap([], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
|
|
627
|
-
return
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
560
|
}
|
|
631
|
-
|
|
632
|
-
{
|
|
633
|
-
if(_1.PVariant) {
|
|
561
|
+
if(_1.PVariant && _1.name_ === "List$Link" && _1.patterns_.length === 2) {
|
|
634
562
|
const at_ = _1.at_;
|
|
635
|
-
if(_1.name_ === "List$Link") {
|
|
636
|
-
if(_1.patterns_.length > 0) {
|
|
637
563
|
const head_ = _1.patterns_[0];
|
|
638
|
-
if(_1.patterns_.length > 1) {
|
|
639
564
|
const tail_ = _1.patterns_[1];
|
|
640
|
-
if(_1.patterns_.length === 2) {
|
|
641
565
|
const itemType_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, at_);
|
|
642
566
|
const listType_ = ff_compiler_Syntax.TConstructor(at_, ff_compiler_Inference.core_("List"), [itemType_]);
|
|
643
567
|
ff_compiler_Unification.Unification_unify(self_.unification_, at_, expected_, listType_);
|
|
644
568
|
const headVariables_ = ff_compiler_Inference.Inference_inferPattern(self_, environment_, itemType_, head_);
|
|
645
569
|
const tailVariables_ = ff_compiler_Inference.Inference_inferPattern(self_, environment_, listType_, tail_);
|
|
646
570
|
return ff_core_Map.Map_addAll(headVariables_, tailVariables_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
|
|
647
|
-
return
|
|
648
571
|
}
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
{
|
|
655
572
|
if(_1.PVariant) {
|
|
656
573
|
const at_ = _1.at_;
|
|
657
574
|
const name_ = _1.name_;
|
|
@@ -668,7 +585,6 @@ return ff_core_List.List_foldLeft(ff_core_List.List_map(ff_core_List.List_zip(pa
|
|
|
668
585
|
const pattern_ = _1.first_;
|
|
669
586
|
const parameter_ = _1.second_;
|
|
670
587
|
return ff_compiler_Inference.Inference_inferPattern(self_, environment_, parameter_.valueType_, pattern_)
|
|
671
|
-
return
|
|
672
588
|
}
|
|
673
589
|
})), ff_core_Map.empty_(), ((_w1, _w2) => {
|
|
674
590
|
return ff_core_Map.Map_addAll(_w1, _w2, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
|
|
@@ -677,7 +593,6 @@ return
|
|
|
677
593
|
}
|
|
678
594
|
}
|
|
679
595
|
}
|
|
680
|
-
}
|
|
681
596
|
|
|
682
597
|
export function Inference_inferTerm(self_, environment_, expected_, term_) {
|
|
683
598
|
const hookRecordTypeBox_ = (ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, term_.at_)
|
|
@@ -693,31 +608,18 @@ return term_
|
|
|
693
608
|
}
|
|
694
609
|
{
|
|
695
610
|
const _1 = term_;
|
|
696
|
-
{
|
|
697
611
|
if(_1.EString) {
|
|
698
612
|
return literal_("String")
|
|
699
|
-
return
|
|
700
613
|
}
|
|
701
|
-
}
|
|
702
|
-
{
|
|
703
614
|
if(_1.EChar) {
|
|
704
615
|
return literal_("Char")
|
|
705
|
-
return
|
|
706
|
-
}
|
|
707
616
|
}
|
|
708
|
-
{
|
|
709
617
|
if(_1.EInt) {
|
|
710
618
|
return literal_("Int")
|
|
711
|
-
return
|
|
712
619
|
}
|
|
713
|
-
}
|
|
714
|
-
{
|
|
715
620
|
if(_1.EFloat) {
|
|
716
621
|
return literal_("Float")
|
|
717
|
-
return
|
|
718
|
-
}
|
|
719
622
|
}
|
|
720
|
-
{
|
|
721
623
|
if(_1.EVariable) {
|
|
722
624
|
const e_ = _1;
|
|
723
625
|
return ff_core_Option.Option_else(ff_core_Option.Option_map(ff_compiler_Inference.Inference_lookup(self_, environment_, expected_, e_.at_, e_.name_, [], ff_core_Option.None()), ((instantiated_) => {
|
|
@@ -732,8 +634,6 @@ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Sy
|
|
|
732
634
|
}))
|
|
733
635
|
return
|
|
734
636
|
}
|
|
735
|
-
}
|
|
736
|
-
{
|
|
737
637
|
if(_1.EField) {
|
|
738
638
|
const e_ = _1;
|
|
739
639
|
const recordType_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, e_.at_);
|
|
@@ -745,13 +645,11 @@ _w1.value_ = ff_core_Option.Some(recordType_)
|
|
|
745
645
|
const record_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, recordType_, e_.record_);
|
|
746
646
|
{
|
|
747
647
|
const _1 = ff_compiler_Unification.Unification_substitute(self_.unification_, recordType_);
|
|
748
|
-
{
|
|
749
|
-
const t_ = _1;
|
|
750
648
|
if(_1.TConstructor) {
|
|
649
|
+
const t_ = _1;
|
|
751
650
|
const name_ = _1.name_;
|
|
752
651
|
const typeArguments_ = _1.generics_;
|
|
753
|
-
|
|
754
|
-
if(_guard1) {
|
|
652
|
+
if(ff_core_String.String_startsWith(name_, "Record$", 0)) {
|
|
755
653
|
if(ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, e_.at_)) {
|
|
756
654
|
const symbolHook_ = ff_compiler_LspHook.SymbolHook(e_.field_, e_.at_, e_.at_);
|
|
757
655
|
const noEffect_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, e_.at_);
|
|
@@ -763,14 +661,13 @@ return (_w1.second_ === e_.field_)
|
|
|
763
661
|
})), ((_w1) => {
|
|
764
662
|
return _w1.first_
|
|
765
663
|
})), ((index_) => {
|
|
766
|
-
const t1_ = ff_core_List.
|
|
664
|
+
const t1_ = (typeArguments_[index_] ?? ff_core_List.internalGrab_(typeArguments_, index_));
|
|
767
665
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t1_);
|
|
768
666
|
{
|
|
769
667
|
const _1 = e_;
|
|
770
668
|
{
|
|
771
669
|
const _c = _1;
|
|
772
670
|
return ff_compiler_Syntax.EField(_c.at_, _c.newtype_, record_, _c.field_)
|
|
773
|
-
return
|
|
774
671
|
}
|
|
775
672
|
}
|
|
776
673
|
})), (() => {
|
|
@@ -783,31 +680,24 @@ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Sy
|
|
|
783
680
|
return
|
|
784
681
|
}
|
|
785
682
|
}
|
|
786
|
-
}
|
|
787
|
-
{
|
|
788
|
-
const t_ = _1;
|
|
789
683
|
if(_1.TConstructor) {
|
|
684
|
+
const t_ = _1;
|
|
790
685
|
const name_ = _1.name_;
|
|
791
686
|
const typeArguments_ = _1.generics_;
|
|
792
687
|
const memberPrefix_ = (name_ + "_");
|
|
793
688
|
const memberName_ = (memberPrefix_ + e_.field_);
|
|
794
689
|
{
|
|
795
690
|
const _1 = ff_compiler_Inference.Inference_lookup(self_, environment_, expected_, e_.at_, memberName_, typeArguments_, ff_core_Option.None());
|
|
796
|
-
{
|
|
797
691
|
if(_1.Some) {
|
|
798
692
|
const instantiated_ = _1.value_;
|
|
799
|
-
|
|
800
|
-
if(_guard1) {
|
|
693
|
+
if((!instantiated_.scheme_.isVariable_)) {
|
|
801
694
|
const signature_ = (((_c) => {
|
|
802
695
|
return ff_compiler_Syntax.Signature(_c.at_, _c.name_, _c.member_, _c.generics_, _c.constraints_, ff_core_List.List_dropFirst(instantiated_.scheme_.signature_.parameters_, 1), _c.returnType_, _c.effect_)
|
|
803
696
|
}))(instantiated_.scheme_.signature_);
|
|
804
697
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, recordType_, ff_core_List.List_grab(instantiated_.scheme_.signature_.parameters_, 0).valueType_);
|
|
805
698
|
return ff_compiler_Inference.Inference_inferEtaExpansion(self_, environment_, expected_, e_.at_, signature_, term_)
|
|
806
|
-
return
|
|
807
|
-
}
|
|
808
699
|
}
|
|
809
700
|
}
|
|
810
|
-
{
|
|
811
701
|
if(_1.Some) {
|
|
812
702
|
const instantiated_ = _1.value_;
|
|
813
703
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, instantiated_.scheme_.signature_.returnType_);
|
|
@@ -816,43 +706,26 @@ const _1 = e_;
|
|
|
816
706
|
{
|
|
817
707
|
const _c = _1;
|
|
818
708
|
return ff_compiler_Syntax.EField(_c.at_, instantiated_.scheme_.isNewtype_, record_, _c.field_)
|
|
819
|
-
return
|
|
820
709
|
}
|
|
821
710
|
}
|
|
822
711
|
return
|
|
823
712
|
}
|
|
824
|
-
}
|
|
825
|
-
{
|
|
826
713
|
if(_1.None) {
|
|
827
714
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(e_.at_, ((("No such field " + e_.field_) + " on type: ") + ff_compiler_Syntax.Type_show(t_, []))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
828
|
-
return
|
|
829
|
-
}
|
|
830
715
|
}
|
|
831
716
|
}
|
|
832
717
|
return
|
|
833
718
|
}
|
|
834
|
-
|
|
835
|
-
{
|
|
836
|
-
if(_1.TVariable) {
|
|
837
|
-
const _guard1 = ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_);
|
|
838
|
-
if(_guard1) {
|
|
719
|
+
if(_1.TVariable && ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
|
|
839
720
|
return term_
|
|
840
|
-
return
|
|
841
721
|
}
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
{
|
|
845
722
|
if(_1.TVariable) {
|
|
846
723
|
const index_ = _1.index_;
|
|
847
724
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(e_.at_, ((("No such field " + e_.field_) + " on unknown type: $") + index_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
848
|
-
return
|
|
849
|
-
}
|
|
850
725
|
}
|
|
851
726
|
}
|
|
852
727
|
return
|
|
853
728
|
}
|
|
854
|
-
}
|
|
855
|
-
{
|
|
856
729
|
if(_1.EWildcard) {
|
|
857
730
|
const e_ = _1;
|
|
858
731
|
return ff_core_Option.Option_grab(ff_core_Option.Option_map(ff_compiler_Inference.Inference_lookup(self_, environment_, expected_, e_.at_, ("_w" + e_.index_), [], ff_core_Option.None()), ((instantiated_) => {
|
|
@@ -861,8 +734,6 @@ return term_
|
|
|
861
734
|
})))
|
|
862
735
|
return
|
|
863
736
|
}
|
|
864
|
-
}
|
|
865
|
-
{
|
|
866
737
|
if(_1.EList) {
|
|
867
738
|
const at_ = _1.at_;
|
|
868
739
|
const t_ = _1.elementType_;
|
|
@@ -881,8 +752,6 @@ return
|
|
|
881
752
|
})))
|
|
882
753
|
return
|
|
883
754
|
}
|
|
884
|
-
}
|
|
885
|
-
{
|
|
886
755
|
if(_1.ESequential) {
|
|
887
756
|
const at_ = _1.at_;
|
|
888
757
|
const before_ = _1.before_;
|
|
@@ -893,12 +762,10 @@ ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.InferSequen
|
|
|
893
762
|
const newExpected_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, at_);
|
|
894
763
|
{
|
|
895
764
|
const _1 = before_;
|
|
896
|
-
{
|
|
897
|
-
if(_1.EPipe) {
|
|
765
|
+
if(_1.EPipe && _1.function_.ELambda) {
|
|
898
766
|
const at1_ = _1.at_;
|
|
899
767
|
const value_ = _1.value_;
|
|
900
768
|
const effect1_ = _1.effect_;
|
|
901
|
-
if(_1.function_.ELambda) {
|
|
902
769
|
const at2_ = _1.function_.at_;
|
|
903
770
|
const at3_ = _1.function_.lambda_.at_;
|
|
904
771
|
const effect3_ = _1.function_.lambda_.effect_;
|
|
@@ -910,42 +777,30 @@ const _1 = case_;
|
|
|
910
777
|
{
|
|
911
778
|
const _c = _1;
|
|
912
779
|
return ff_compiler_Syntax.MatchCase(_c.at_, _c.patterns_, _c.guards_, ff_compiler_Syntax.ESequential(case_.at_, case_.body_, e_))
|
|
913
|
-
return
|
|
914
780
|
}
|
|
915
781
|
}
|
|
916
782
|
}));
|
|
917
783
|
const newPipe_ = ff_compiler_Syntax.EPipe(at1_, value_, effect1_, ff_compiler_Syntax.ELambda(at2_, ff_compiler_Syntax.Lambda(at3_, effect3_, newCases_)));
|
|
918
784
|
{
|
|
919
785
|
const _1 = after_;
|
|
920
|
-
{
|
|
921
|
-
if(_1.EVariant) {
|
|
786
|
+
if(_1.EVariant && _1.name_ === "ff:core/Unit.Unit") {
|
|
922
787
|
const at_ = _1.at_;
|
|
923
|
-
if(_1.name_ === "ff:core/Unit.Unit") {
|
|
924
788
|
const unitType_ = ff_compiler_Syntax.TConstructor(at_, ff_compiler_Inference.core_("Unit"), []);
|
|
925
789
|
ff_compiler_Unification.Unification_unify(self_.unification_, at_, expected_, unitType_);
|
|
926
790
|
return ff_compiler_Inference.Inference_inferTerm(self_, environment_, newExpected_, newPipe_)
|
|
927
|
-
return
|
|
928
|
-
}
|
|
929
|
-
}
|
|
930
791
|
}
|
|
931
792
|
{
|
|
932
793
|
return ff_compiler_Syntax.ESequential(at_, ff_compiler_Inference.Inference_inferTerm(self_, environment_, newExpected_, newPipe_), ff_compiler_Inference.Inference_inferTerm(self_, environment_, expected_, after_))
|
|
933
|
-
return
|
|
934
794
|
}
|
|
935
795
|
}
|
|
936
796
|
return
|
|
937
797
|
}
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
798
|
{
|
|
941
799
|
return ff_compiler_Syntax.ESequential(at_, ff_compiler_Inference.Inference_inferTerm(self_, environment_, newExpected_, before_), ff_compiler_Inference.Inference_inferTerm(self_, environment_, expected_, after_))
|
|
942
|
-
return
|
|
943
800
|
}
|
|
944
801
|
}
|
|
945
802
|
return
|
|
946
803
|
}
|
|
947
|
-
}
|
|
948
|
-
{
|
|
949
804
|
if(_1.ELet) {
|
|
950
805
|
const e_ = _1;
|
|
951
806
|
const noEffect_ = ff_compiler_Syntax.TConstructor(e_.at_, "ff:core/Nothing.Nothing", []);
|
|
@@ -958,64 +813,29 @@ const _1 = e_;
|
|
|
958
813
|
{
|
|
959
814
|
const _c = _1;
|
|
960
815
|
return ff_compiler_Syntax.ELet(_c.at_, _c.mutable_, _c.name_, _c.valueType_, ff_compiler_Inference.Inference_inferTerm(self_, environment_, e_.valueType_, e_.value_), ff_compiler_Inference.Inference_inferTerm(self_, environment2_, expected_, e_.body_))
|
|
961
|
-
return
|
|
962
816
|
}
|
|
963
817
|
}
|
|
964
818
|
return
|
|
965
819
|
}
|
|
966
|
-
}
|
|
967
|
-
{
|
|
968
820
|
if(_1.ELambda) {
|
|
969
821
|
const at_ = _1.at_;
|
|
970
822
|
const l_ = _1.lambda_;
|
|
971
823
|
do {
|
|
972
824
|
const _1 = l_.cases_;
|
|
973
|
-
{
|
|
974
|
-
if(_1.length > 0) {
|
|
975
|
-
if(_1[0].patterns_.length === 0) {
|
|
976
|
-
if(_1[0].guards_.length === 0) {
|
|
977
|
-
if(_1[0].body_.EVariable) {
|
|
825
|
+
if(_1.length === 1 && _1[0].patterns_.length === 0 && _1[0].guards_.length === 0 && _1[0].body_.EVariable && _1[0].body_.name_ === "") {
|
|
978
826
|
const insideAt_ = _1[0].body_.at_;
|
|
979
|
-
if(
|
|
980
|
-
if(_1.length === 1) {
|
|
981
|
-
const _guard1 = ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, insideAt_);
|
|
982
|
-
if(_guard1) {
|
|
827
|
+
if(ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, insideAt_)) {
|
|
983
828
|
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.InferLambdaStartHook(self_.unification_, environment_, expected_))
|
|
984
829
|
break
|
|
985
830
|
}
|
|
986
831
|
}
|
|
987
|
-
|
|
988
|
-
}
|
|
989
|
-
}
|
|
990
|
-
}
|
|
991
|
-
}
|
|
992
|
-
}
|
|
993
|
-
{
|
|
994
|
-
if(_1.length > 0) {
|
|
995
|
-
if(_1[0].patterns_.length === 0) {
|
|
996
|
-
if(_1[0].guards_.length === 0) {
|
|
997
|
-
if(_1[0].body_.ESequential) {
|
|
998
|
-
if(_1[0].body_.before_.EVariable) {
|
|
832
|
+
if(_1.length === 1 && _1[0].patterns_.length === 0 && _1[0].guards_.length === 0 && _1[0].body_.ESequential && _1[0].body_.before_.EVariable && _1[0].body_.before_.name_ === "" && _1[0].body_.after_.EVariant && _1[0].body_.after_.name_ === "ff:core/Unit.Unit") {
|
|
999
833
|
const insideAt_ = _1[0].body_.before_.at_;
|
|
1000
|
-
if(
|
|
1001
|
-
if(_1[0].body_.after_.EVariant) {
|
|
1002
|
-
if(_1[0].body_.after_.name_ === "ff:core/Unit.Unit") {
|
|
1003
|
-
if(_1.length === 1) {
|
|
1004
|
-
const _guard1 = ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, insideAt_);
|
|
1005
|
-
if(_guard1) {
|
|
834
|
+
if(ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, insideAt_)) {
|
|
1006
835
|
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.InferLambdaStartHook(self_.unification_, environment_, expected_))
|
|
1007
836
|
break
|
|
1008
837
|
}
|
|
1009
838
|
}
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
1012
|
-
}
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
}
|
|
1019
839
|
{
|
|
1020
840
|
|
|
1021
841
|
break
|
|
@@ -1023,10 +843,7 @@ break
|
|
|
1023
843
|
} while(false);
|
|
1024
844
|
const lambda_ = ff_compiler_Inference.Inference_inferLambda(self_, environment_, expected_, l_);
|
|
1025
845
|
return ff_compiler_Syntax.ELambda(at_, lambda_)
|
|
1026
|
-
return
|
|
1027
846
|
}
|
|
1028
|
-
}
|
|
1029
|
-
{
|
|
1030
847
|
if(_1.EVariant) {
|
|
1031
848
|
const e_ = _1;
|
|
1032
849
|
const instantiated_ = ff_core_Option.Option_else(ff_compiler_Inference.Inference_lookup(self_, environment_, expected_, e_.at_, e_.name_, e_.typeArguments_, e_.arguments_), (() => {
|
|
@@ -1048,8 +865,6 @@ return
|
|
|
1048
865
|
}
|
|
1049
866
|
return
|
|
1050
867
|
}
|
|
1051
|
-
}
|
|
1052
|
-
{
|
|
1053
868
|
if(_1.EVariantIs) {
|
|
1054
869
|
const e_ = _1;
|
|
1055
870
|
const instantiated_ = ff_core_Option.Option_else(ff_compiler_Inference.Inference_lookup(self_, environment_, expected_, e_.at_, e_.name_, e_.typeArguments_, ff_core_Option.None()), (() => {
|
|
@@ -1077,8 +892,6 @@ return
|
|
|
1077
892
|
}
|
|
1078
893
|
return
|
|
1079
894
|
}
|
|
1080
|
-
}
|
|
1081
|
-
{
|
|
1082
895
|
if(_1.ECopy) {
|
|
1083
896
|
const e_ = _1;
|
|
1084
897
|
const scheme_ = ff_core_Option.Option_else(ff_compiler_Inference.Inference_lookup(self_, environment_, expected_, e_.at_, e_.name_, [], ff_core_Option.None()), (() => {
|
|
@@ -1105,7 +918,6 @@ const _1 = f_;
|
|
|
1105
918
|
{
|
|
1106
919
|
const _c = _1;
|
|
1107
920
|
return ff_compiler_Syntax.Argument(_c.at_, ff_core_Option.Some(f_.name_), _c.value_)
|
|
1108
|
-
return
|
|
1109
921
|
}
|
|
1110
922
|
}
|
|
1111
923
|
}));
|
|
@@ -1128,7 +940,6 @@ const at_ = _1.at_;
|
|
|
1128
940
|
const name_ = _1.name_;
|
|
1129
941
|
const value_ = _1.value_;
|
|
1130
942
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ("Unknown parameter: " + name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
1131
|
-
return
|
|
1132
943
|
}
|
|
1133
944
|
}));
|
|
1134
945
|
const arguments_ = ff_core_List.List_map(parameterNames_, ((name_) => {
|
|
@@ -1139,7 +950,6 @@ return (_w1.name_ === name_)
|
|
|
1139
950
|
const at_ = _1.at_;
|
|
1140
951
|
const value_ = _1.value_;
|
|
1141
952
|
return ff_compiler_Syntax.Argument(at_, ff_core_Option.Some(name_), value_)
|
|
1142
|
-
return
|
|
1143
953
|
}
|
|
1144
954
|
})), (() => {
|
|
1145
955
|
const at_ = (((_c) => {
|
|
@@ -1152,10 +962,7 @@ const body_ = ff_compiler_Syntax.EVariant(e_.at_, e_.name_, [], ff_core_Option.S
|
|
|
1152
962
|
const effect_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, e_.at_);
|
|
1153
963
|
const e1_ = ff_compiler_Syntax.EPipe(e_.at_, e_.record_, effect_, ff_compiler_Syntax.ELambda(e_.at_, ff_compiler_Syntax.Lambda(e_.at_, effect_, [ff_compiler_Syntax.MatchCase(e_.at_, [ff_compiler_Syntax.PVariable(e_.at_, ff_core_Option.Some("_c"))], [], body_)])));
|
|
1154
964
|
return ff_compiler_Inference.Inference_inferTerm(self_, environment_, expected_, e1_)
|
|
1155
|
-
return
|
|
1156
965
|
}
|
|
1157
|
-
}
|
|
1158
|
-
{
|
|
1159
966
|
if(_1.EPipe) {
|
|
1160
967
|
const e_ = _1;
|
|
1161
968
|
const valueType_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, e_.at_);
|
|
@@ -1168,47 +975,37 @@ const _1 = e_;
|
|
|
1168
975
|
{
|
|
1169
976
|
const _c = _1;
|
|
1170
977
|
return ff_compiler_Syntax.EPipe(_c.at_, value_, _c.effect_, function_)
|
|
1171
|
-
return
|
|
1172
978
|
}
|
|
1173
979
|
}
|
|
1174
980
|
return
|
|
1175
981
|
}
|
|
1176
|
-
}
|
|
1177
|
-
{
|
|
1178
982
|
if(_1.ECall) {
|
|
1179
983
|
const e_ = _1;
|
|
1180
984
|
if((ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_) && (((_1) => {
|
|
1181
|
-
{
|
|
1182
985
|
if(_1.StaticCall) {
|
|
1183
986
|
return true
|
|
1184
|
-
return
|
|
1185
|
-
}
|
|
1186
987
|
}
|
|
1187
988
|
{
|
|
1188
989
|
return false
|
|
1189
|
-
return
|
|
1190
990
|
}
|
|
1191
991
|
}))(e_.target_))) {
|
|
1192
992
|
return term_
|
|
1193
993
|
} else {
|
|
1194
994
|
const call_ = (((_1) => {
|
|
1195
|
-
{
|
|
1196
995
|
if(_1.DynamicCall) {
|
|
1197
996
|
const call_ = _1;
|
|
1198
|
-
return
|
|
1199
|
-
|
|
997
|
+
return {
|
|
998
|
+
function_: call_.function_,
|
|
999
|
+
tailCall_: call_.tailCall_
|
|
1200
1000
|
}
|
|
1001
|
+
return
|
|
1201
1002
|
}
|
|
1202
|
-
{
|
|
1203
1003
|
if(_1.StaticCall) {
|
|
1204
1004
|
return ff_compiler_Inference.fail_(e_.at_, "Internal error: Static calls not expected in the Inference phase")
|
|
1205
|
-
return
|
|
1206
|
-
}
|
|
1207
1005
|
}
|
|
1208
1006
|
}))(e_.target_);
|
|
1209
1007
|
{
|
|
1210
1008
|
const _1 = call_.function_;
|
|
1211
|
-
{
|
|
1212
1009
|
if(_1.EVariable) {
|
|
1213
1010
|
const variableAt_ = _1.at_;
|
|
1214
1011
|
const x_ = _1.name_;
|
|
@@ -1219,7 +1016,6 @@ return ff_compiler_Inference.Inference_inferOperator(self_, environment_, expect
|
|
|
1219
1016
|
} else {
|
|
1220
1017
|
{
|
|
1221
1018
|
const _1 = ff_compiler_Inference.Inference_lookup(self_, environment_, expected_, e_.at_, x_, e_.typeArguments_, ff_core_Option.Some(e_.arguments_));
|
|
1222
|
-
{
|
|
1223
1019
|
if(_1.Some) {
|
|
1224
1020
|
const instantiated_ = _1.value_;
|
|
1225
1021
|
if(instantiated_.scheme_.isVariable_) {
|
|
@@ -1230,19 +1026,13 @@ return ff_compiler_Inference.Inference_inferFunctionCall(self_, environment_, ex
|
|
|
1230
1026
|
}
|
|
1231
1027
|
return
|
|
1232
1028
|
}
|
|
1233
|
-
}
|
|
1234
|
-
{
|
|
1235
1029
|
if(_1.None) {
|
|
1236
1030
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(variableAt_, ("No such function: " + x_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
1237
|
-
return
|
|
1238
|
-
}
|
|
1239
1031
|
}
|
|
1240
1032
|
}
|
|
1241
1033
|
}
|
|
1242
1034
|
return
|
|
1243
1035
|
}
|
|
1244
|
-
}
|
|
1245
|
-
{
|
|
1246
1036
|
if(_1.EField) {
|
|
1247
1037
|
const f_ = _1;
|
|
1248
1038
|
const recordType_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, f_.at_);
|
|
@@ -1261,71 +1051,46 @@ return ff_compiler_Syntax.EField(_c.at_, _c.newtype_, record_, _c.field_)
|
|
|
1261
1051
|
}))(e_);
|
|
1262
1052
|
{
|
|
1263
1053
|
const _1 = ff_compiler_Unification.Unification_substitute(self_.unification_, recordType_);
|
|
1264
|
-
{
|
|
1265
|
-
const t_ = _1;
|
|
1266
1054
|
if(_1.TConstructor) {
|
|
1055
|
+
const t_ = _1;
|
|
1267
1056
|
const name_ = _1.name_;
|
|
1268
1057
|
const methodName_ = ((name_ + "_") + f_.field_);
|
|
1269
1058
|
const arguments_ = [ff_compiler_Syntax.Argument(f_.record_.at_, ff_core_Option.None(), f_.record_), ...e_.arguments_];
|
|
1270
1059
|
{
|
|
1271
1060
|
const _1 = ff_compiler_Inference.Inference_lookup(self_, environment_, expected_, f_.at_, methodName_, [], ff_core_Option.Some(arguments_));
|
|
1272
|
-
{
|
|
1273
1061
|
if(_1.Some) {
|
|
1274
1062
|
const instantiated_ = _1.value_;
|
|
1275
|
-
|
|
1276
|
-
if(_guard1) {
|
|
1063
|
+
if((!instantiated_.scheme_.isVariable_)) {
|
|
1277
1064
|
return ff_compiler_Inference.Inference_inferMethodCall(self_, environment_, expected_, instantiated_.scheme_.signature_, instantiated_.typeArguments_, e2_, record_, recordType_, methodName_)
|
|
1278
|
-
return
|
|
1279
1065
|
}
|
|
1280
1066
|
}
|
|
1281
|
-
}
|
|
1282
|
-
{
|
|
1283
1067
|
if(_1.Some) {
|
|
1284
1068
|
const instantiated_ = _1.value_;
|
|
1285
1069
|
return ff_compiler_Inference.Inference_inferLambdaCall(self_, environment_, expected_, e2_)
|
|
1286
|
-
return
|
|
1287
|
-
}
|
|
1288
1070
|
}
|
|
1289
|
-
{
|
|
1290
1071
|
if(_1.None) {
|
|
1291
1072
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(f_.at_, ((("No such field " + f_.field_) + " on type: ") + ff_compiler_Syntax.Type_show(t_, []))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
1292
|
-
return
|
|
1293
|
-
}
|
|
1294
1073
|
}
|
|
1295
1074
|
}
|
|
1296
1075
|
return
|
|
1297
1076
|
}
|
|
1298
|
-
|
|
1299
|
-
{
|
|
1300
|
-
if(_1.TVariable) {
|
|
1301
|
-
const _guard1 = ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_);
|
|
1302
|
-
if(_guard1) {
|
|
1077
|
+
if(_1.TVariable && ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
|
|
1303
1078
|
return ff_compiler_Inference.Inference_inferLambdaCall(self_, environment_, expected_, e2_)
|
|
1304
|
-
return
|
|
1305
|
-
}
|
|
1306
1079
|
}
|
|
1307
|
-
}
|
|
1308
|
-
{
|
|
1309
1080
|
if(_1.TVariable) {
|
|
1310
1081
|
const index_ = _1.index_;
|
|
1311
1082
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(f_.at_, ((("No such field " + f_.field_) + " on unknown type: $") + index_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
1312
|
-
return
|
|
1313
|
-
}
|
|
1314
1083
|
}
|
|
1315
1084
|
}
|
|
1316
1085
|
return
|
|
1317
1086
|
}
|
|
1318
|
-
}
|
|
1319
1087
|
{
|
|
1320
1088
|
return ff_compiler_Inference.Inference_inferLambdaCall(self_, environment_, expected_, term_)
|
|
1321
|
-
return
|
|
1322
1089
|
}
|
|
1323
1090
|
}
|
|
1324
1091
|
}
|
|
1325
1092
|
return
|
|
1326
1093
|
}
|
|
1327
|
-
}
|
|
1328
|
-
{
|
|
1329
1094
|
if(_1.ERecord) {
|
|
1330
1095
|
const e_ = _1;
|
|
1331
1096
|
const fields_ = ff_core_List.List_sortBy(e_.fields_, ((_w1) => {
|
|
@@ -1347,7 +1112,6 @@ const _1 = field_;
|
|
|
1347
1112
|
{
|
|
1348
1113
|
const _c = _1;
|
|
1349
1114
|
return ff_compiler_Syntax.Field(_c.at_, _c.name_, ff_compiler_Inference.Inference_inferTerm(self_, environment_, t_, field_.value_))
|
|
1350
|
-
return
|
|
1351
1115
|
}
|
|
1352
1116
|
}
|
|
1353
1117
|
return
|
|
@@ -1358,13 +1122,10 @@ const _1 = e_;
|
|
|
1358
1122
|
{
|
|
1359
1123
|
const _c = _1;
|
|
1360
1124
|
return ff_compiler_Syntax.ERecord(_c.at_, newFields_)
|
|
1361
|
-
return
|
|
1362
1125
|
}
|
|
1363
1126
|
}
|
|
1364
1127
|
return
|
|
1365
1128
|
}
|
|
1366
|
-
}
|
|
1367
|
-
{
|
|
1368
1129
|
if(_1.EFunctions) {
|
|
1369
1130
|
const at_ = _1.at_;
|
|
1370
1131
|
const functions_ = _1.functions_;
|
|
@@ -1381,10 +1142,7 @@ return ff_compiler_Inference.Inference_inferFunctionDefinition(self_, environmen
|
|
|
1381
1142
|
}));
|
|
1382
1143
|
const newBody_ = ff_compiler_Inference.Inference_inferTerm(self_, environment2_, expected_, body_);
|
|
1383
1144
|
return ff_compiler_Syntax.EFunctions(at_, newFunctions_, newBody_)
|
|
1384
|
-
return
|
|
1385
|
-
}
|
|
1386
1145
|
}
|
|
1387
|
-
{
|
|
1388
1146
|
if(_1.EAssign) {
|
|
1389
1147
|
const e_ = _1;
|
|
1390
1148
|
return ff_core_Option.Option_else(ff_core_Option.Option_map(ff_compiler_Inference.Inference_lookup(self_, environment_, expected_, e_.at_, e_.variable_, [], ff_core_Option.None()), ((instantiated_) => {
|
|
@@ -1395,7 +1153,6 @@ const _1 = e_;
|
|
|
1395
1153
|
{
|
|
1396
1154
|
const _c = _1;
|
|
1397
1155
|
return ff_compiler_Syntax.EAssign(_c.at_, _c.operator_, _c.variable_, value_)
|
|
1398
|
-
return
|
|
1399
1156
|
}
|
|
1400
1157
|
}
|
|
1401
1158
|
} else {
|
|
@@ -1406,91 +1163,63 @@ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Sy
|
|
|
1406
1163
|
}))
|
|
1407
1164
|
return
|
|
1408
1165
|
}
|
|
1409
|
-
}
|
|
1410
|
-
{
|
|
1411
1166
|
if(_1.EAssignField) {
|
|
1412
1167
|
const e_ = _1;
|
|
1413
1168
|
const recordType_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, e_.at_);
|
|
1414
1169
|
const record_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, recordType_, e_.record_);
|
|
1415
1170
|
{
|
|
1416
1171
|
const _1 = ff_compiler_Unification.Unification_substitute(self_.unification_, recordType_);
|
|
1417
|
-
{
|
|
1418
|
-
const t_ = _1;
|
|
1419
1172
|
if(_1.TConstructor) {
|
|
1173
|
+
const t_ = _1;
|
|
1420
1174
|
const name_ = _1.name_;
|
|
1421
1175
|
const typeArguments_ = _1.generics_;
|
|
1422
|
-
|
|
1423
|
-
if(_guard1) {
|
|
1176
|
+
if(ff_core_String.String_startsWith(name_, "Record$", 0)) {
|
|
1424
1177
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(e_.at_, ("Can't assign fields of anonymous records: " + e_.field_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
1425
|
-
return
|
|
1426
1178
|
}
|
|
1427
1179
|
}
|
|
1428
|
-
}
|
|
1429
|
-
{
|
|
1430
|
-
const t_ = _1;
|
|
1431
1180
|
if(_1.TConstructor) {
|
|
1181
|
+
const t_ = _1;
|
|
1432
1182
|
const name_ = _1.name_;
|
|
1433
1183
|
const typeArguments_ = _1.generics_;
|
|
1434
1184
|
const methodName_ = ((name_ + "_") + e_.field_);
|
|
1435
1185
|
{
|
|
1436
1186
|
const _1 = ff_compiler_Inference.Inference_lookup(self_, environment_, expected_, e_.at_, methodName_, typeArguments_, ff_core_Option.None());
|
|
1437
|
-
{
|
|
1438
1187
|
if(_1.Some) {
|
|
1439
1188
|
const instantiated_ = _1.value_;
|
|
1440
|
-
|
|
1441
|
-
if(_guard1) {
|
|
1189
|
+
if((instantiated_.scheme_.isMutable_ || ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_))) {
|
|
1442
1190
|
const value_ = ff_compiler_Inference.Inference_inferAssignment(self_, environment_, expected_, e_.at_, e_.operator_, e_.value_, instantiated_.scheme_.signature_);
|
|
1443
1191
|
{
|
|
1444
1192
|
const _1 = e_;
|
|
1445
1193
|
{
|
|
1446
1194
|
const _c = _1;
|
|
1447
1195
|
return ff_compiler_Syntax.EAssignField(_c.at_, _c.operator_, record_, _c.field_, value_)
|
|
1448
|
-
return
|
|
1449
1196
|
}
|
|
1450
1197
|
}
|
|
1451
1198
|
return
|
|
1452
1199
|
}
|
|
1453
1200
|
}
|
|
1454
|
-
}
|
|
1455
|
-
{
|
|
1456
1201
|
if(_1.Some) {
|
|
1457
1202
|
const instantiated_ = _1.value_;
|
|
1458
1203
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(e_.at_, ((("Can't assign an immutable field " + e_.field_) + " on type: ") + ff_compiler_Syntax.Type_show(t_, []))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
1459
|
-
return
|
|
1460
1204
|
}
|
|
1461
|
-
}
|
|
1462
|
-
{
|
|
1463
1205
|
if(_1.None) {
|
|
1464
1206
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(e_.at_, ((("No such field " + e_.field_) + " on type: ") + ff_compiler_Syntax.Type_show(t_, []))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
1465
|
-
return
|
|
1466
|
-
}
|
|
1467
1207
|
}
|
|
1468
1208
|
}
|
|
1469
1209
|
return
|
|
1470
1210
|
}
|
|
1211
|
+
if(_1.TVariable && ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
|
|
1212
|
+
return term_
|
|
1471
1213
|
}
|
|
1472
|
-
{
|
|
1473
1214
|
if(_1.TVariable) {
|
|
1474
|
-
const
|
|
1475
|
-
|
|
1476
|
-
return term_
|
|
1477
|
-
return
|
|
1478
|
-
}
|
|
1479
|
-
}
|
|
1480
|
-
}
|
|
1481
|
-
{
|
|
1482
|
-
if(_1.TVariable) {
|
|
1483
|
-
const index_ = _1.index_;
|
|
1484
|
-
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(e_.at_, ((("No such field " + e_.field_) + " on unknown type: $") + index_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
1485
|
-
return
|
|
1486
|
-
}
|
|
1215
|
+
const index_ = _1.index_;
|
|
1216
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(e_.at_, ((("No such field " + e_.field_) + " on unknown type: $") + index_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
1487
1217
|
}
|
|
1488
1218
|
}
|
|
1489
1219
|
return
|
|
1490
1220
|
}
|
|
1491
1221
|
}
|
|
1492
1222
|
}
|
|
1493
|
-
}
|
|
1494
1223
|
|
|
1495
1224
|
export function Inference_inferAssignment(self_, environment_, expected_, at_, operator_, value_, signature_) {
|
|
1496
1225
|
const t_ = signature_.returnType_;
|
|
@@ -1505,32 +1234,17 @@ return newValue_
|
|
|
1505
1234
|
}
|
|
1506
1235
|
|
|
1507
1236
|
export function Inference_inferMethodCall(self_, environment_, expected_, signature_, instantiation_, term_, record_, recordType_, name_) {
|
|
1508
|
-
const e_ = (((_1) => {
|
|
1509
1237
|
{
|
|
1238
|
+
const _1 = term_;
|
|
1510
1239
|
if(_1.ECall) {
|
|
1511
1240
|
const e_ = _1;
|
|
1512
|
-
|
|
1513
|
-
return
|
|
1514
|
-
}
|
|
1515
|
-
}
|
|
1516
|
-
{
|
|
1517
|
-
return ff_compiler_Inference.fail_(term_.at_, "Call expected")
|
|
1518
|
-
return
|
|
1519
|
-
}
|
|
1520
|
-
}))(term_);
|
|
1521
|
-
const call_ = (((_1) => {
|
|
1522
|
-
{
|
|
1241
|
+
const tailCall_ = (((_1) => {
|
|
1523
1242
|
if(_1.DynamicCall) {
|
|
1524
1243
|
const call_ = _1;
|
|
1525
|
-
return call_
|
|
1526
|
-
return
|
|
1527
|
-
}
|
|
1244
|
+
return call_.tailCall_
|
|
1528
1245
|
}
|
|
1529
|
-
{
|
|
1530
1246
|
if(_1.StaticCall) {
|
|
1531
1247
|
return ff_compiler_Inference.fail_(e_.at_, "Internal error: Static calls not expected in inferMethodCall")
|
|
1532
|
-
return
|
|
1533
|
-
}
|
|
1534
1248
|
}
|
|
1535
1249
|
}))(e_.target_);
|
|
1536
1250
|
const selfParameter_ = ff_core_List.List_grabFirst(signature_.parameters_);
|
|
@@ -1543,41 +1257,32 @@ ff_compiler_Unification.Unification_affect(self_.unification_, term_.at_, signat
|
|
|
1543
1257
|
const _1 = e_;
|
|
1544
1258
|
{
|
|
1545
1259
|
const _c = _1;
|
|
1546
|
-
return ff_compiler_Syntax.ECall(_c.at_, ff_compiler_Syntax.StaticCall(name_,
|
|
1260
|
+
return ff_compiler_Syntax.ECall(_c.at_, ff_compiler_Syntax.StaticCall(name_, tailCall_, false), signature_.effect_, ff_core_List.List_map(instantiation_, ((_w1) => {
|
|
1547
1261
|
return _w1.second_
|
|
1548
1262
|
})), [selfArgument_, ...arguments_], _c.dictionaries_)
|
|
1549
1263
|
return
|
|
1550
1264
|
}
|
|
1551
1265
|
}
|
|
1552
|
-
}
|
|
1553
|
-
|
|
1554
|
-
export function Inference_inferFunctionCall(self_, environment_, expected_, signature_, instanceCall_, instantiation_, term_, name_) {
|
|
1555
|
-
const e_ = (((_1) => {
|
|
1556
|
-
{
|
|
1557
|
-
if(_1.ECall) {
|
|
1558
|
-
const e_ = _1;
|
|
1559
|
-
return e_
|
|
1560
1266
|
return
|
|
1561
1267
|
}
|
|
1562
|
-
}
|
|
1563
1268
|
{
|
|
1564
1269
|
return ff_compiler_Inference.fail_(term_.at_, "Call expected")
|
|
1565
|
-
return
|
|
1566
1270
|
}
|
|
1567
|
-
}
|
|
1568
|
-
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
export function Inference_inferFunctionCall(self_, environment_, expected_, signature_, instanceCall_, instantiation_, term_, name_) {
|
|
1569
1275
|
{
|
|
1276
|
+
const _1 = term_;
|
|
1277
|
+
if(_1.ECall) {
|
|
1278
|
+
const e_ = _1;
|
|
1279
|
+
const tailCall_ = (((_1) => {
|
|
1570
1280
|
if(_1.DynamicCall) {
|
|
1571
1281
|
const call_ = _1;
|
|
1572
|
-
return call_
|
|
1573
|
-
return
|
|
1282
|
+
return call_.tailCall_
|
|
1574
1283
|
}
|
|
1575
|
-
}
|
|
1576
|
-
{
|
|
1577
1284
|
if(_1.StaticCall) {
|
|
1578
1285
|
return ff_compiler_Inference.fail_(e_.at_, "Internal error: Static calls not expected in inferFunctionCall")
|
|
1579
|
-
return
|
|
1580
|
-
}
|
|
1581
1286
|
}
|
|
1582
1287
|
}))(e_.target_);
|
|
1583
1288
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, signature_.returnType_);
|
|
@@ -1587,50 +1292,41 @@ ff_compiler_Unification.Unification_affect(self_.unification_, term_.at_, signat
|
|
|
1587
1292
|
const _1 = e_;
|
|
1588
1293
|
{
|
|
1589
1294
|
const _c = _1;
|
|
1590
|
-
return ff_compiler_Syntax.ECall(_c.at_, ff_compiler_Syntax.StaticCall(name_,
|
|
1295
|
+
return ff_compiler_Syntax.ECall(_c.at_, ff_compiler_Syntax.StaticCall(name_, tailCall_, instanceCall_), signature_.effect_, ff_core_List.List_map(instantiation_, ((_w1) => {
|
|
1591
1296
|
return _w1.second_
|
|
1592
1297
|
})), arguments_, _c.dictionaries_)
|
|
1593
1298
|
return
|
|
1594
1299
|
}
|
|
1595
1300
|
}
|
|
1301
|
+
return
|
|
1302
|
+
}
|
|
1303
|
+
{
|
|
1304
|
+
return ff_compiler_Inference.fail_(term_.at_, "Call expected")
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1596
1307
|
}
|
|
1597
1308
|
|
|
1598
1309
|
export function Inference_inferLambdaCall(self_, environment_, expected_, term_) {
|
|
1599
|
-
const e_ = (((_1) => {
|
|
1600
1310
|
{
|
|
1311
|
+
const _1 = term_;
|
|
1601
1312
|
if(_1.ECall) {
|
|
1602
1313
|
const e_ = _1;
|
|
1603
|
-
return e_
|
|
1604
|
-
return
|
|
1605
|
-
}
|
|
1606
|
-
}
|
|
1607
|
-
{
|
|
1608
|
-
return ff_compiler_Inference.fail_(term_.at_, "Call expected")
|
|
1609
|
-
return
|
|
1610
|
-
}
|
|
1611
|
-
}))(term_);
|
|
1612
1314
|
const call_ = (((_1) => {
|
|
1613
|
-
{
|
|
1614
1315
|
if(_1.DynamicCall) {
|
|
1615
1316
|
const call_ = _1;
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1317
|
+
if((!call_.tailCall_)) {
|
|
1318
|
+
return {
|
|
1319
|
+
function_: call_.function_,
|
|
1320
|
+
tailCall_: call_.tailCall_
|
|
1620
1321
|
}
|
|
1322
|
+
return
|
|
1621
1323
|
}
|
|
1622
1324
|
}
|
|
1623
|
-
{
|
|
1624
1325
|
if(_1.DynamicCall) {
|
|
1625
1326
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(e_.at_, "Tailcalls not supported on lambda functions"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
1626
|
-
return
|
|
1627
|
-
}
|
|
1628
1327
|
}
|
|
1629
|
-
{
|
|
1630
1328
|
if(_1.StaticCall) {
|
|
1631
1329
|
return ff_compiler_Inference.fail_(e_.at_, "Internal error: Static calls not expected in inferLambdaCall")
|
|
1632
|
-
return
|
|
1633
|
-
}
|
|
1634
1330
|
}
|
|
1635
1331
|
}))(e_.target_);
|
|
1636
1332
|
const effect_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, term_.at_);
|
|
@@ -1651,7 +1347,6 @@ const _1 = argument_;
|
|
|
1651
1347
|
{
|
|
1652
1348
|
const _c = _1;
|
|
1653
1349
|
return ff_compiler_Syntax.Argument(_c.at_, _c.name_, ff_compiler_Inference.Inference_inferTerm(self_, environment_, t_, argument_.value_))
|
|
1654
|
-
return
|
|
1655
1350
|
}
|
|
1656
1351
|
}
|
|
1657
1352
|
return
|
|
@@ -1671,31 +1366,25 @@ return ff_compiler_Syntax.DynamicCall(function_, _c.tailCall_)
|
|
|
1671
1366
|
return
|
|
1672
1367
|
}
|
|
1673
1368
|
}
|
|
1369
|
+
return
|
|
1370
|
+
}
|
|
1371
|
+
{
|
|
1372
|
+
return ff_compiler_Inference.fail_(term_.at_, "Call expected")
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1674
1375
|
}
|
|
1675
1376
|
|
|
1676
1377
|
export function Inference_inferOperator(self_, environment_, expected_, operator_, term_) {
|
|
1677
|
-
const e_ = (((_1) => {
|
|
1678
1378
|
{
|
|
1379
|
+
const _1 = term_;
|
|
1679
1380
|
if(_1.ECall) {
|
|
1680
1381
|
const e_ = _1;
|
|
1681
|
-
return e_
|
|
1682
|
-
return
|
|
1683
|
-
}
|
|
1684
|
-
}
|
|
1685
|
-
{
|
|
1686
|
-
return ff_compiler_Inference.fail_(term_.at_, "Call expected")
|
|
1687
|
-
return
|
|
1688
|
-
}
|
|
1689
|
-
}))(term_);
|
|
1690
1382
|
const target_ = ff_compiler_Syntax.StaticCall(operator_, false, false);
|
|
1691
1383
|
{
|
|
1692
1384
|
const _1 = e_.arguments_;
|
|
1693
|
-
{
|
|
1694
|
-
if(_1.length > 0) {
|
|
1695
|
-
const a1_ = _1[0];
|
|
1696
1385
|
if(_1.length === 1) {
|
|
1697
|
-
const
|
|
1698
|
-
if(
|
|
1386
|
+
const a1_ = _1[0];
|
|
1387
|
+
if((operator_ === "!")) {
|
|
1699
1388
|
const t_ = ff_compiler_Syntax.TConstructor(e_.at_, ff_compiler_Inference.core_("Bool"), []);
|
|
1700
1389
|
const e1_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, t_, a1_.value_);
|
|
1701
1390
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t_);
|
|
@@ -1712,52 +1401,33 @@ return
|
|
|
1712
1401
|
return
|
|
1713
1402
|
}
|
|
1714
1403
|
}
|
|
1715
|
-
}
|
|
1716
|
-
}
|
|
1717
|
-
{
|
|
1718
|
-
if(_1.length > 0) {
|
|
1719
|
-
const a1_ = _1[0];
|
|
1720
1404
|
if(_1.length === 1) {
|
|
1721
|
-
const
|
|
1722
|
-
if(
|
|
1405
|
+
const a1_ = _1[0];
|
|
1406
|
+
if((operator_ === "-")) {
|
|
1723
1407
|
const t1_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, e_.at_);
|
|
1724
1408
|
const e1_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, t1_, a1_.value_);
|
|
1725
1409
|
do {
|
|
1726
1410
|
const _1 = ff_compiler_Unification.Unification_substitute(self_.unification_, t1_);
|
|
1727
|
-
{
|
|
1728
|
-
if(_1.TConstructor) {
|
|
1411
|
+
if(_1.TConstructor && _1.generics_.length === 0) {
|
|
1729
1412
|
const name_ = _1.name_;
|
|
1730
|
-
if(
|
|
1731
|
-
const _guard1 = (name_ === ff_compiler_Inference.core_("Float"));
|
|
1732
|
-
if(_guard1) {
|
|
1413
|
+
if((name_ === ff_compiler_Inference.core_("Float"))) {
|
|
1733
1414
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t1_)
|
|
1734
1415
|
break
|
|
1735
1416
|
}
|
|
1736
1417
|
}
|
|
1737
|
-
|
|
1738
|
-
}
|
|
1739
|
-
{
|
|
1740
|
-
if(_1.TConstructor) {
|
|
1418
|
+
if(_1.TConstructor && _1.generics_.length === 0) {
|
|
1741
1419
|
const name_ = _1.name_;
|
|
1742
|
-
if(
|
|
1743
|
-
const _guard1 = (name_ === ff_compiler_Inference.core_("Int"));
|
|
1744
|
-
if(_guard1) {
|
|
1420
|
+
if((name_ === ff_compiler_Inference.core_("Int"))) {
|
|
1745
1421
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t1_)
|
|
1746
1422
|
break
|
|
1747
1423
|
}
|
|
1748
1424
|
}
|
|
1749
|
-
|
|
1750
|
-
}
|
|
1751
|
-
{
|
|
1752
|
-
const _guard1 = ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_);
|
|
1753
|
-
if(_guard1) {
|
|
1425
|
+
if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
|
|
1754
1426
|
|
|
1755
1427
|
break
|
|
1756
1428
|
}
|
|
1757
|
-
}
|
|
1758
1429
|
{
|
|
1759
1430
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(e_.at_, "Operators on unknown types not currently supported"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
1760
|
-
break
|
|
1761
1431
|
}
|
|
1762
1432
|
} while(false);
|
|
1763
1433
|
{
|
|
@@ -1773,16 +1443,10 @@ return
|
|
|
1773
1443
|
return
|
|
1774
1444
|
}
|
|
1775
1445
|
}
|
|
1776
|
-
|
|
1777
|
-
}
|
|
1778
|
-
{
|
|
1779
|
-
if(_1.length > 0) {
|
|
1446
|
+
if(_1.length === 2) {
|
|
1780
1447
|
const a1_ = _1[0];
|
|
1781
|
-
if(_1.length > 1) {
|
|
1782
1448
|
const a2_ = _1[1];
|
|
1783
|
-
if(
|
|
1784
|
-
const _guard1 = ((operator_ === "||") || (operator_ === "&&"));
|
|
1785
|
-
if(_guard1) {
|
|
1449
|
+
if(((operator_ === "||") || (operator_ === "&&"))) {
|
|
1786
1450
|
const t_ = ff_compiler_Syntax.TConstructor(e_.at_, ff_compiler_Inference.core_("Bool"), []);
|
|
1787
1451
|
const e1_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, t_, a1_.value_);
|
|
1788
1452
|
const e2_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, t_, a2_.value_);
|
|
@@ -1802,17 +1466,10 @@ return
|
|
|
1802
1466
|
return
|
|
1803
1467
|
}
|
|
1804
1468
|
}
|
|
1805
|
-
|
|
1806
|
-
}
|
|
1807
|
-
}
|
|
1808
|
-
{
|
|
1809
|
-
if(_1.length > 0) {
|
|
1469
|
+
if(_1.length === 2) {
|
|
1810
1470
|
const a1_ = _1[0];
|
|
1811
|
-
if(_1.length > 1) {
|
|
1812
1471
|
const a2_ = _1[1];
|
|
1813
|
-
if(
|
|
1814
|
-
const _guard1 = ((operator_ === "===") || (operator_ === "!=="));
|
|
1815
|
-
if(_guard1) {
|
|
1472
|
+
if(((operator_ === "===") || (operator_ === "!=="))) {
|
|
1816
1473
|
const t1_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, e_.at_);
|
|
1817
1474
|
const e1_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, t1_, a1_.value_);
|
|
1818
1475
|
const e2_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, t1_, a2_.value_);
|
|
@@ -1832,17 +1489,10 @@ return
|
|
|
1832
1489
|
return
|
|
1833
1490
|
}
|
|
1834
1491
|
}
|
|
1835
|
-
|
|
1836
|
-
}
|
|
1837
|
-
}
|
|
1838
|
-
{
|
|
1839
|
-
if(_1.length > 0) {
|
|
1492
|
+
if(_1.length === 2) {
|
|
1840
1493
|
const a1_ = _1[0];
|
|
1841
|
-
if(_1.length > 1) {
|
|
1842
1494
|
const a2_ = _1[1];
|
|
1843
|
-
if(
|
|
1844
|
-
const _guard1 = ((((((operator_ === "+") || (operator_ === "-")) || (operator_ === "*")) || (operator_ === "/")) || (operator_ === "%")) || (operator_ === "^"));
|
|
1845
|
-
if(_guard1) {
|
|
1495
|
+
if(((((((operator_ === "+") || (operator_ === "-")) || (operator_ === "*")) || (operator_ === "/")) || (operator_ === "%")) || (operator_ === "^"))) {
|
|
1846
1496
|
const t1_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, e_.at_);
|
|
1847
1497
|
const t2_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, e_.at_);
|
|
1848
1498
|
const e1_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, t1_, a1_.value_);
|
|
@@ -1850,149 +1500,73 @@ const e2_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, t2_,
|
|
|
1850
1500
|
const magic_ = ((t_) => {
|
|
1851
1501
|
{
|
|
1852
1502
|
const _1 = ff_compiler_Unification.Unification_substitute(self_.unification_, t_);
|
|
1853
|
-
{
|
|
1854
|
-
if(_1.TConstructor) {
|
|
1503
|
+
if(_1.TConstructor && _1.generics_.length === 0) {
|
|
1855
1504
|
const name_ = _1.name_;
|
|
1856
|
-
if(
|
|
1857
|
-
const _guard1 = (name_ === ff_compiler_Inference.core_("Float"));
|
|
1858
|
-
if(_guard1) {
|
|
1505
|
+
if((name_ === ff_compiler_Inference.core_("Float"))) {
|
|
1859
1506
|
return ff_core_Option.Some("Float")
|
|
1860
|
-
return
|
|
1861
1507
|
}
|
|
1862
1508
|
}
|
|
1863
|
-
|
|
1864
|
-
}
|
|
1865
|
-
{
|
|
1866
|
-
if(_1.TConstructor) {
|
|
1509
|
+
if(_1.TConstructor && _1.generics_.length === 0) {
|
|
1867
1510
|
const name_ = _1.name_;
|
|
1868
|
-
if(
|
|
1869
|
-
const _guard1 = (name_ === ff_compiler_Inference.core_("Int"));
|
|
1870
|
-
if(_guard1) {
|
|
1511
|
+
if((name_ === ff_compiler_Inference.core_("Int"))) {
|
|
1871
1512
|
return ff_core_Option.Some("Int")
|
|
1872
|
-
return
|
|
1873
|
-
}
|
|
1874
1513
|
}
|
|
1875
1514
|
}
|
|
1876
|
-
|
|
1877
|
-
{
|
|
1878
|
-
if(_1.TConstructor) {
|
|
1515
|
+
if(_1.TConstructor && _1.generics_.length === 0) {
|
|
1879
1516
|
const name_ = _1.name_;
|
|
1880
|
-
if(
|
|
1881
|
-
const _guard1 = ((operator_ === "+") && (name_ === ff_compiler_Inference.core_("String")));
|
|
1882
|
-
if(_guard1) {
|
|
1517
|
+
if(((operator_ === "+") && (name_ === ff_compiler_Inference.core_("String")))) {
|
|
1883
1518
|
return ff_core_Option.Some("String")
|
|
1884
|
-
return
|
|
1885
|
-
}
|
|
1886
|
-
}
|
|
1887
1519
|
}
|
|
1888
1520
|
}
|
|
1889
1521
|
{
|
|
1890
1522
|
return ff_core_Option.None()
|
|
1891
|
-
return
|
|
1892
1523
|
}
|
|
1893
1524
|
}
|
|
1894
1525
|
});
|
|
1895
1526
|
const chooseType_ = ((_1, _2) => {
|
|
1896
|
-
{
|
|
1897
|
-
if(_1.Some) {
|
|
1898
|
-
if(_1.value_ === "String") {
|
|
1899
|
-
if(_2.Some) {
|
|
1527
|
+
if(_1.Some && _1.value_ === "String" && _2.Some) {
|
|
1900
1528
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t1_)
|
|
1901
1529
|
return
|
|
1902
1530
|
}
|
|
1903
|
-
|
|
1904
|
-
}
|
|
1905
|
-
}
|
|
1906
|
-
{
|
|
1907
|
-
if(_1.Some) {
|
|
1908
|
-
if(_2.Some) {
|
|
1909
|
-
if(_2.value_ === "String") {
|
|
1531
|
+
if(_1.Some && _2.Some && _2.value_ === "String") {
|
|
1910
1532
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t2_)
|
|
1911
1533
|
return
|
|
1912
1534
|
}
|
|
1913
|
-
|
|
1914
|
-
}
|
|
1915
|
-
}
|
|
1916
|
-
{
|
|
1917
|
-
if(_1.Some) {
|
|
1918
|
-
if(_1.value_ === "Float") {
|
|
1919
|
-
if(_2.Some) {
|
|
1535
|
+
if(_1.Some && _1.value_ === "Float" && _2.Some) {
|
|
1920
1536
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t1_)
|
|
1921
1537
|
return
|
|
1922
1538
|
}
|
|
1923
|
-
|
|
1924
|
-
}
|
|
1925
|
-
}
|
|
1926
|
-
{
|
|
1927
|
-
if(_1.Some) {
|
|
1928
|
-
if(_2.Some) {
|
|
1929
|
-
if(_2.value_ === "Float") {
|
|
1539
|
+
if(_1.Some && _2.Some && _2.value_ === "Float") {
|
|
1930
1540
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t2_)
|
|
1931
1541
|
return
|
|
1932
1542
|
}
|
|
1933
|
-
|
|
1934
|
-
}
|
|
1935
|
-
}
|
|
1936
|
-
{
|
|
1937
|
-
if(_1.Some) {
|
|
1938
|
-
if(_1.value_ === "Int") {
|
|
1939
|
-
if(_2.Some) {
|
|
1543
|
+
if(_1.Some && _1.value_ === "Int" && _2.Some) {
|
|
1940
1544
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t1_)
|
|
1941
1545
|
return
|
|
1942
1546
|
}
|
|
1943
|
-
|
|
1944
|
-
}
|
|
1945
|
-
}
|
|
1946
|
-
{
|
|
1947
|
-
if(_1.Some) {
|
|
1948
|
-
if(_2.Some) {
|
|
1949
|
-
if(_2.value_ === "Int") {
|
|
1547
|
+
if(_1.Some && _2.Some && _2.value_ === "Int") {
|
|
1950
1548
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t2_)
|
|
1951
1549
|
return
|
|
1952
1550
|
}
|
|
1953
|
-
|
|
1954
|
-
}
|
|
1955
|
-
}
|
|
1956
|
-
{
|
|
1957
|
-
if(_1.Some) {
|
|
1958
|
-
if(_2.None) {
|
|
1551
|
+
if(_1.Some && _2.None) {
|
|
1959
1552
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, t1_, t2_);
|
|
1960
1553
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t1_)
|
|
1961
1554
|
return
|
|
1962
1555
|
}
|
|
1963
|
-
|
|
1964
|
-
}
|
|
1965
|
-
{
|
|
1966
|
-
if(_1.None) {
|
|
1967
|
-
if(_2.Some) {
|
|
1556
|
+
if(_1.None && _2.Some) {
|
|
1968
1557
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, t2_, t1_);
|
|
1969
1558
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t2_)
|
|
1970
1559
|
return
|
|
1971
1560
|
}
|
|
1972
|
-
|
|
1973
|
-
}
|
|
1974
|
-
{
|
|
1975
|
-
const _guard1 = ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_);
|
|
1976
|
-
if(_guard1) {
|
|
1561
|
+
if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
|
|
1977
1562
|
|
|
1978
1563
|
return
|
|
1979
1564
|
}
|
|
1980
|
-
|
|
1981
|
-
{
|
|
1982
|
-
if(_1.Some) {
|
|
1983
|
-
if(_2.Some) {
|
|
1565
|
+
if(_1.Some && _2.Some) {
|
|
1984
1566
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(e_.at_, "Operators on these types not currently supported"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
1985
|
-
return
|
|
1986
|
-
}
|
|
1987
1567
|
}
|
|
1988
|
-
|
|
1989
|
-
{
|
|
1990
|
-
if(_1.None) {
|
|
1991
|
-
if(_2.None) {
|
|
1568
|
+
if(_1.None && _2.None) {
|
|
1992
1569
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(e_.at_, "Operators on unknown types not currently supported"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
1993
|
-
return
|
|
1994
|
-
}
|
|
1995
|
-
}
|
|
1996
1570
|
}
|
|
1997
1571
|
});
|
|
1998
1572
|
chooseType_(magic_(t1_), magic_(t2_));
|
|
@@ -2011,19 +1585,17 @@ return
|
|
|
2011
1585
|
return
|
|
2012
1586
|
}
|
|
2013
1587
|
}
|
|
1588
|
+
if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
|
|
1589
|
+
return term_
|
|
2014
1590
|
}
|
|
1591
|
+
{
|
|
1592
|
+
return ff_compiler_Inference.fail_(e_.at_, ("Unknown operator: " + operator_))
|
|
2015
1593
|
}
|
|
2016
1594
|
}
|
|
2017
|
-
{
|
|
2018
|
-
const _guard1 = ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_);
|
|
2019
|
-
if(_guard1) {
|
|
2020
|
-
return term_
|
|
2021
1595
|
return
|
|
2022
1596
|
}
|
|
2023
|
-
}
|
|
2024
1597
|
{
|
|
2025
|
-
return ff_compiler_Inference.fail_(
|
|
2026
|
-
return
|
|
1598
|
+
return ff_compiler_Inference.fail_(term_.at_, "Call expected")
|
|
2027
1599
|
}
|
|
2028
1600
|
}
|
|
2029
1601
|
}
|
|
@@ -2103,7 +1675,6 @@ ff_core_Array.Array_delete(remainingArguments_, _w1, 1)
|
|
|
2103
1675
|
}));
|
|
2104
1676
|
const e2_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, t_, e_);
|
|
2105
1677
|
return ff_compiler_Syntax.Argument(at_, ff_core_Option.Some(p_.name_), e2_)
|
|
2106
|
-
return
|
|
2107
1678
|
}
|
|
2108
1679
|
})), (() => {
|
|
2109
1680
|
return defaultArgument_()
|
|
@@ -2112,21 +1683,17 @@ return defaultArgument_()
|
|
|
2112
1683
|
}));
|
|
2113
1684
|
if((!ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_))) {
|
|
2114
1685
|
ff_core_Option.Option_each(ff_core_Array.Array_first(remainingArguments_), ((_1) => {
|
|
2115
|
-
{
|
|
2116
|
-
const callAt_ = _1.at_;
|
|
2117
1686
|
if(_1.name_.None) {
|
|
1687
|
+
const callAt_ = _1.at_;
|
|
2118
1688
|
ff_compiler_Inference.fail_(callAt_, "Too many arguments")
|
|
2119
1689
|
return
|
|
2120
1690
|
}
|
|
2121
|
-
}
|
|
2122
|
-
{
|
|
2123
|
-
const callAt_ = _1.at_;
|
|
2124
1691
|
if(_1.name_.Some) {
|
|
1692
|
+
const callAt_ = _1.at_;
|
|
2125
1693
|
const n_ = _1.name_.value_;
|
|
2126
1694
|
ff_compiler_Inference.fail_(callAt_, ("Unknown argument: " + n_))
|
|
2127
1695
|
return
|
|
2128
1696
|
}
|
|
2129
|
-
}
|
|
2130
1697
|
}));
|
|
2131
1698
|
return newArguments_
|
|
2132
1699
|
} else {
|
|
@@ -2136,7 +1703,6 @@ const _1 = a_;
|
|
|
2136
1703
|
{
|
|
2137
1704
|
const _c = _1;
|
|
2138
1705
|
return ff_compiler_Syntax.Argument(_c.at_, _c.name_, ff_compiler_Inference.Inference_inferTerm(self_, environment_, ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, a_.at_), a_.value_))
|
|
2139
|
-
return
|
|
2140
1706
|
}
|
|
2141
1707
|
}
|
|
2142
1708
|
}))]
|
|
@@ -2199,7 +1765,6 @@ const _1 = p_;
|
|
|
2199
1765
|
{
|
|
2200
1766
|
const _c = _1;
|
|
2201
1767
|
return ff_compiler_Syntax.Parameter(_c.at_, _c.mutable_, _c.name_, ff_compiler_Unification.Unification_instantiate(self_.unification_, instantiationMap_, p_.valueType_), _c.default_)
|
|
2202
|
-
return
|
|
2203
1768
|
}
|
|
2204
1769
|
}
|
|
2205
1770
|
}));
|
|
@@ -2220,14 +1785,12 @@ return ff_compiler_Environment.Scheme(_c.isVariable_, _c.isMutable_, _c.isNewtyp
|
|
|
2220
1785
|
if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, scheme_.signature_.at_))) {
|
|
2221
1786
|
const symbolHook_ = ff_compiler_LspHook.SymbolHook(symbol_, at_, scheme_.signature_.at_);
|
|
2222
1787
|
const emittedHook_ = (((_1) => {
|
|
2223
|
-
{
|
|
2224
1788
|
if(_1.InferLookupHook) {
|
|
2225
1789
|
const h_ = _1;
|
|
2226
1790
|
h_.symbol_.value_ = symbolHook_;
|
|
2227
1791
|
h_.instantiated_.value_ = ff_core_Option.Some(instantiated_)
|
|
2228
1792
|
return
|
|
2229
1793
|
}
|
|
2230
|
-
}
|
|
2231
1794
|
{
|
|
2232
1795
|
|
|
2233
1796
|
return
|
|
@@ -2274,7 +1837,6 @@ const _1 = definition_;
|
|
|
2274
1837
|
{
|
|
2275
1838
|
const _c = _1;
|
|
2276
1839
|
return ff_compiler_Syntax.DTrait(_c.at_, _c.name_, _c.generics_, _c.constraints_, _c.generatorParameters_, _c.methods_, _c.methodDefaults_, _c.methodGenerators_)
|
|
2277
|
-
return
|
|
2278
1840
|
}
|
|
2279
1841
|
}
|
|
2280
1842
|
}
|
|
@@ -2322,7 +1884,6 @@ const _1 = p_;
|
|
|
2322
1884
|
{
|
|
2323
1885
|
const _c = _1;
|
|
2324
1886
|
return ff_compiler_Syntax.Parameter(_c.at_, _c.mutable_, _c.name_, ff_compiler_Unification.Unification_instantiate(self_.unification_, instantiationMap_, p_.valueType_), _c.default_)
|
|
2325
|
-
return
|
|
2326
1887
|
}
|
|
2327
1888
|
}
|
|
2328
1889
|
}));
|
|
@@ -2363,7 +1924,6 @@ const _1 = definition_;
|
|
|
2363
1924
|
{
|
|
2364
1925
|
const _c = _1;
|
|
2365
1926
|
return ff_compiler_Syntax.DLet(_c.at_, _c.name_, _c.variableType_, value_)
|
|
2366
|
-
return
|
|
2367
1927
|
}
|
|
2368
1928
|
}
|
|
2369
1929
|
}
|
|
@@ -2385,7 +1945,6 @@ const _1 = case_;
|
|
|
2385
1945
|
{
|
|
2386
1946
|
const _c = _1;
|
|
2387
1947
|
return ff_compiler_Syntax.MatchCase(_c.at_, [ff_compiler_Syntax.PVariable(method_.at_, ff_core_Option.None()), ...case_.patterns_], _c.guards_, _c.body_)
|
|
2388
|
-
return
|
|
2389
1948
|
}
|
|
2390
1949
|
}
|
|
2391
1950
|
})))
|
|
@@ -2405,7 +1964,6 @@ const _1 = definition_;
|
|
|
2405
1964
|
{
|
|
2406
1965
|
const _c = _1;
|
|
2407
1966
|
return ff_compiler_Syntax.DExtend(_c.at_, _c.name_, _c.generics_, _c.constraints_, _c.type_, functions_)
|
|
2408
|
-
return
|
|
2409
1967
|
}
|
|
2410
1968
|
}
|
|
2411
1969
|
}
|
|
@@ -2448,35 +2006,25 @@ return
|
|
|
2448
2006
|
export async function Inference_inferLambda$(self_, environment_, expected_, lambda_, $task) {
|
|
2449
2007
|
const unitName_ = ff_compiler_Inference.core_("Unit");
|
|
2450
2008
|
const returnsUnit_ = (((_1) => {
|
|
2451
|
-
{
|
|
2452
2009
|
if(_1.TConstructor) {
|
|
2453
2010
|
const name_ = _1.name_;
|
|
2454
2011
|
const ts_ = _1.generics_;
|
|
2455
|
-
|
|
2456
|
-
if(_guard1) {
|
|
2012
|
+
if(ff_core_String.String_startsWith(name_, "Function$", 0)) {
|
|
2457
2013
|
{
|
|
2458
2014
|
const _1 = ff_core_List.List_grabLast(ts_);
|
|
2459
|
-
{
|
|
2460
|
-
if(_1.TConstructor) {
|
|
2015
|
+
if(_1.TConstructor && _1.generics_.length === 0) {
|
|
2461
2016
|
const n_ = _1.name_;
|
|
2462
|
-
if(_1.generics_.length === 0) {
|
|
2463
2017
|
return (n_ === unitName_)
|
|
2464
|
-
return
|
|
2465
|
-
}
|
|
2466
|
-
}
|
|
2467
2018
|
}
|
|
2468
2019
|
{
|
|
2469
2020
|
return false
|
|
2470
|
-
return
|
|
2471
2021
|
}
|
|
2472
2022
|
}
|
|
2473
2023
|
return
|
|
2474
2024
|
}
|
|
2475
2025
|
}
|
|
2476
|
-
}
|
|
2477
2026
|
{
|
|
2478
2027
|
return false
|
|
2479
|
-
return
|
|
2480
2028
|
}
|
|
2481
2029
|
}))(ff_compiler_Unification.Unification_substitute(self_.unification_, expected_));
|
|
2482
2030
|
const cases_ = ((!returnsUnit_)
|
|
@@ -2487,7 +2035,6 @@ const _1 = c_;
|
|
|
2487
2035
|
{
|
|
2488
2036
|
const _c = _1;
|
|
2489
2037
|
return ff_compiler_Syntax.MatchCase(_c.at_, _c.patterns_, _c.guards_, ff_compiler_Syntax.ESequential(c_.at_, c_.body_, ff_compiler_Syntax.EVariant(c_.at_, unitName_, [], ff_core_Option.None())))
|
|
2490
|
-
return
|
|
2491
2038
|
}
|
|
2492
2039
|
}
|
|
2493
2040
|
})));
|
|
@@ -2525,7 +2072,6 @@ const at_ = _2.first_;
|
|
|
2525
2072
|
const type_ = _2.second_;
|
|
2526
2073
|
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", []);
|
|
2527
2074
|
return ff_compiler_Environment.Scheme(true, false, false, false, ff_compiler_Syntax.Signature(at_, name_, false, [], [], [], type_, noEffect_))
|
|
2528
|
-
return
|
|
2529
2075
|
}
|
|
2530
2076
|
}), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
2531
2077
|
{
|
|
@@ -2533,7 +2079,6 @@ const _1 = environment_;
|
|
|
2533
2079
|
{
|
|
2534
2080
|
const _c = _1;
|
|
2535
2081
|
return ff_compiler_Environment.Environment(_c.modulePrefix_, ff_core_Map.Map_addAll(environment1_.symbols_, symbols_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.imports_, _c.effect_, _c.selfVariable_)
|
|
2536
|
-
return
|
|
2537
2082
|
}
|
|
2538
2083
|
}
|
|
2539
2084
|
return
|
|
@@ -2550,7 +2095,6 @@ const at_ = _2.first_;
|
|
|
2550
2095
|
const type_ = _2.second_;
|
|
2551
2096
|
const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing", []);
|
|
2552
2097
|
return ff_compiler_Environment.Scheme(true, false, false, false, ff_compiler_Syntax.Signature(at_, name_, false, [], [], [], type_, noEffect_))
|
|
2553
|
-
return
|
|
2554
2098
|
}
|
|
2555
2099
|
}), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
2556
2100
|
ff_core_Array.Array_push(guards_, (((_c) => {
|
|
@@ -2561,7 +2105,6 @@ const _1 = environment2_;
|
|
|
2561
2105
|
{
|
|
2562
2106
|
const _c = _1;
|
|
2563
2107
|
return ff_compiler_Environment.Environment(_c.modulePrefix_, ff_core_Map.Map_addAll(environment2_.symbols_, symbols_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), _c.traits_, _c.imports_, _c.effect_, _c.selfVariable_)
|
|
2564
|
-
return
|
|
2565
2108
|
}
|
|
2566
2109
|
}
|
|
2567
2110
|
}));
|
|
@@ -2570,7 +2113,6 @@ const _1 = case_;
|
|
|
2570
2113
|
{
|
|
2571
2114
|
const _c = _1;
|
|
2572
2115
|
return ff_compiler_Syntax.MatchCase(_c.at_, _c.patterns_, ff_core_Array.Array_drain(guards_), ff_compiler_Inference.Inference_inferTerm(self_, environment3_, returnType_, case_.body_))
|
|
2573
|
-
return
|
|
2574
2116
|
}
|
|
2575
2117
|
}
|
|
2576
2118
|
}
|
|
@@ -2578,24 +2120,17 @@ return
|
|
|
2578
2120
|
export async function Inference_inferPattern$(self_, environment_, expected_, pattern_, $task) {
|
|
2579
2121
|
if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
|
|
2580
2122
|
if((((_1) => {
|
|
2581
|
-
{
|
|
2582
2123
|
if(_1.PVariantAs) {
|
|
2583
2124
|
const at_ = _1.at_;
|
|
2584
2125
|
const variableAt_ = _1.variableAt_;
|
|
2585
2126
|
return ((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, at_) || ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, variableAt_)) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, variableAt_))
|
|
2586
|
-
return
|
|
2587
|
-
}
|
|
2588
2127
|
}
|
|
2589
|
-
{
|
|
2590
2128
|
if(_1.PAlias) {
|
|
2591
2129
|
const at_ = _1.at_;
|
|
2592
2130
|
return (ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, at_))
|
|
2593
|
-
return
|
|
2594
|
-
}
|
|
2595
2131
|
}
|
|
2596
2132
|
{
|
|
2597
2133
|
return ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, pattern_.at_)
|
|
2598
|
-
return
|
|
2599
2134
|
}
|
|
2600
2135
|
}))(pattern_)) {
|
|
2601
2136
|
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.InferPatternHook(self_.unification_, environment_, expected_, pattern_))
|
|
@@ -2607,53 +2142,30 @@ return ff_core_Map.empty_()
|
|
|
2607
2142
|
}
|
|
2608
2143
|
{
|
|
2609
2144
|
const _1 = pattern_;
|
|
2610
|
-
{
|
|
2611
2145
|
if(_1.PString) {
|
|
2612
2146
|
return literal_("String")
|
|
2613
|
-
return
|
|
2614
2147
|
}
|
|
2615
|
-
}
|
|
2616
|
-
{
|
|
2617
2148
|
if(_1.PInt) {
|
|
2618
2149
|
return literal_("Int")
|
|
2619
|
-
return
|
|
2620
|
-
}
|
|
2621
2150
|
}
|
|
2622
|
-
{
|
|
2623
2151
|
if(_1.PChar) {
|
|
2624
2152
|
return literal_("Char")
|
|
2625
|
-
return
|
|
2626
2153
|
}
|
|
2627
|
-
|
|
2628
|
-
{
|
|
2629
|
-
if(_1.PVariable) {
|
|
2154
|
+
if(_1.PVariable && _1.name_.None) {
|
|
2630
2155
|
const at_ = _1.at_;
|
|
2631
|
-
if(_1.name_.None) {
|
|
2632
2156
|
return ff_core_Map.empty_()
|
|
2633
|
-
return
|
|
2634
|
-
}
|
|
2635
|
-
}
|
|
2636
2157
|
}
|
|
2637
|
-
{
|
|
2638
|
-
if(_1.PVariable) {
|
|
2158
|
+
if(_1.PVariable && _1.name_.Some) {
|
|
2639
2159
|
const at_ = _1.at_;
|
|
2640
|
-
if(_1.name_.Some) {
|
|
2641
2160
|
const name_ = _1.name_.value_;
|
|
2642
2161
|
return ff_core_List.List_toMap([ff_core_Pair.Pair(name_, ff_core_Pair.Pair(at_, expected_))], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
|
|
2643
|
-
return
|
|
2644
|
-
}
|
|
2645
2162
|
}
|
|
2646
|
-
}
|
|
2647
|
-
{
|
|
2648
2163
|
if(_1.PAlias) {
|
|
2649
2164
|
const at_ = _1.at_;
|
|
2650
2165
|
const pattern_ = _1.pattern_;
|
|
2651
2166
|
const variable_ = _1.variable_;
|
|
2652
2167
|
return ff_core_Map.Map_add(ff_compiler_Inference.Inference_inferPattern(self_, environment_, expected_, pattern_), variable_, ff_core_Pair.Pair(at_, expected_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
|
|
2653
|
-
return
|
|
2654
|
-
}
|
|
2655
2168
|
}
|
|
2656
|
-
{
|
|
2657
2169
|
if(_1.PVariantAs) {
|
|
2658
2170
|
const at_ = _1.at_;
|
|
2659
2171
|
const name_ = _1.name_;
|
|
@@ -2679,44 +2191,24 @@ return ff_core_Pair.Pair(_w1, ff_core_Pair.Pair(variableAt_, recordType_))
|
|
|
2679
2191
|
})), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
|
|
2680
2192
|
return
|
|
2681
2193
|
}
|
|
2682
|
-
|
|
2683
|
-
{
|
|
2684
|
-
if(_1.PVariant) {
|
|
2194
|
+
if(_1.PVariant && _1.name_ === "List$Empty" && _1.patterns_.length === 0) {
|
|
2685
2195
|
const at_ = _1.at_;
|
|
2686
|
-
if(_1.name_ === "List$Empty") {
|
|
2687
|
-
if(_1.patterns_.length === 0) {
|
|
2688
2196
|
const itemType_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, at_);
|
|
2689
2197
|
const listType_ = ff_compiler_Syntax.TConstructor(at_, ff_compiler_Inference.core_("List"), [itemType_]);
|
|
2690
2198
|
ff_compiler_Unification.Unification_unify(self_.unification_, at_, expected_, listType_);
|
|
2691
2199
|
return ff_core_List.List_toMap([], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
|
|
2692
|
-
return
|
|
2693
|
-
}
|
|
2694
2200
|
}
|
|
2695
|
-
|
|
2696
|
-
}
|
|
2697
|
-
{
|
|
2698
|
-
if(_1.PVariant) {
|
|
2201
|
+
if(_1.PVariant && _1.name_ === "List$Link" && _1.patterns_.length === 2) {
|
|
2699
2202
|
const at_ = _1.at_;
|
|
2700
|
-
if(_1.name_ === "List$Link") {
|
|
2701
|
-
if(_1.patterns_.length > 0) {
|
|
2702
2203
|
const head_ = _1.patterns_[0];
|
|
2703
|
-
if(_1.patterns_.length > 1) {
|
|
2704
2204
|
const tail_ = _1.patterns_[1];
|
|
2705
|
-
if(_1.patterns_.length === 2) {
|
|
2706
2205
|
const itemType_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, at_);
|
|
2707
2206
|
const listType_ = ff_compiler_Syntax.TConstructor(at_, ff_compiler_Inference.core_("List"), [itemType_]);
|
|
2708
2207
|
ff_compiler_Unification.Unification_unify(self_.unification_, at_, expected_, listType_);
|
|
2709
2208
|
const headVariables_ = ff_compiler_Inference.Inference_inferPattern(self_, environment_, itemType_, head_);
|
|
2710
2209
|
const tailVariables_ = ff_compiler_Inference.Inference_inferPattern(self_, environment_, listType_, tail_);
|
|
2711
2210
|
return ff_core_Map.Map_addAll(headVariables_, tailVariables_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
|
|
2712
|
-
return
|
|
2713
|
-
}
|
|
2714
|
-
}
|
|
2715
|
-
}
|
|
2716
|
-
}
|
|
2717
|
-
}
|
|
2718
2211
|
}
|
|
2719
|
-
{
|
|
2720
2212
|
if(_1.PVariant) {
|
|
2721
2213
|
const at_ = _1.at_;
|
|
2722
2214
|
const name_ = _1.name_;
|
|
@@ -2733,7 +2225,6 @@ return ff_core_List.List_foldLeft(ff_core_List.List_map(ff_core_List.List_zip(pa
|
|
|
2733
2225
|
const pattern_ = _1.first_;
|
|
2734
2226
|
const parameter_ = _1.second_;
|
|
2735
2227
|
return ff_compiler_Inference.Inference_inferPattern(self_, environment_, parameter_.valueType_, pattern_)
|
|
2736
|
-
return
|
|
2737
2228
|
}
|
|
2738
2229
|
})), ff_core_Map.empty_(), ((_w1, _w2) => {
|
|
2739
2230
|
return ff_core_Map.Map_addAll(_w1, _w2, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
|
|
@@ -2742,7 +2233,6 @@ return
|
|
|
2742
2233
|
}
|
|
2743
2234
|
}
|
|
2744
2235
|
}
|
|
2745
|
-
}
|
|
2746
2236
|
|
|
2747
2237
|
export async function Inference_inferTerm$(self_, environment_, expected_, term_, $task) {
|
|
2748
2238
|
const hookRecordTypeBox_ = (ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, term_.at_)
|
|
@@ -2758,31 +2248,18 @@ return term_
|
|
|
2758
2248
|
}
|
|
2759
2249
|
{
|
|
2760
2250
|
const _1 = term_;
|
|
2761
|
-
{
|
|
2762
2251
|
if(_1.EString) {
|
|
2763
2252
|
return literal_("String")
|
|
2764
|
-
return
|
|
2765
|
-
}
|
|
2766
2253
|
}
|
|
2767
|
-
{
|
|
2768
2254
|
if(_1.EChar) {
|
|
2769
2255
|
return literal_("Char")
|
|
2770
|
-
return
|
|
2771
2256
|
}
|
|
2772
|
-
}
|
|
2773
|
-
{
|
|
2774
2257
|
if(_1.EInt) {
|
|
2775
2258
|
return literal_("Int")
|
|
2776
|
-
return
|
|
2777
|
-
}
|
|
2778
2259
|
}
|
|
2779
|
-
{
|
|
2780
2260
|
if(_1.EFloat) {
|
|
2781
2261
|
return literal_("Float")
|
|
2782
|
-
return
|
|
2783
|
-
}
|
|
2784
2262
|
}
|
|
2785
|
-
{
|
|
2786
2263
|
if(_1.EVariable) {
|
|
2787
2264
|
const e_ = _1;
|
|
2788
2265
|
return ff_core_Option.Option_else(ff_core_Option.Option_map(ff_compiler_Inference.Inference_lookup(self_, environment_, expected_, e_.at_, e_.name_, [], ff_core_Option.None()), ((instantiated_) => {
|
|
@@ -2797,8 +2274,6 @@ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Sy
|
|
|
2797
2274
|
}))
|
|
2798
2275
|
return
|
|
2799
2276
|
}
|
|
2800
|
-
}
|
|
2801
|
-
{
|
|
2802
2277
|
if(_1.EField) {
|
|
2803
2278
|
const e_ = _1;
|
|
2804
2279
|
const recordType_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, e_.at_);
|
|
@@ -2810,13 +2285,11 @@ _w1.value_ = ff_core_Option.Some(recordType_)
|
|
|
2810
2285
|
const record_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, recordType_, e_.record_);
|
|
2811
2286
|
{
|
|
2812
2287
|
const _1 = ff_compiler_Unification.Unification_substitute(self_.unification_, recordType_);
|
|
2813
|
-
{
|
|
2814
|
-
const t_ = _1;
|
|
2815
2288
|
if(_1.TConstructor) {
|
|
2289
|
+
const t_ = _1;
|
|
2816
2290
|
const name_ = _1.name_;
|
|
2817
2291
|
const typeArguments_ = _1.generics_;
|
|
2818
|
-
|
|
2819
|
-
if(_guard1) {
|
|
2292
|
+
if(ff_core_String.String_startsWith(name_, "Record$", 0)) {
|
|
2820
2293
|
if(ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, e_.at_)) {
|
|
2821
2294
|
const symbolHook_ = ff_compiler_LspHook.SymbolHook(e_.field_, e_.at_, e_.at_);
|
|
2822
2295
|
const noEffect_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, e_.at_);
|
|
@@ -2828,14 +2301,13 @@ return (_w1.second_ === e_.field_)
|
|
|
2828
2301
|
})), ((_w1) => {
|
|
2829
2302
|
return _w1.first_
|
|
2830
2303
|
})), ((index_) => {
|
|
2831
|
-
const t1_ = ff_core_List.
|
|
2304
|
+
const t1_ = (typeArguments_[index_] ?? ff_core_List.internalGrab_(typeArguments_, index_));
|
|
2832
2305
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t1_);
|
|
2833
2306
|
{
|
|
2834
2307
|
const _1 = e_;
|
|
2835
2308
|
{
|
|
2836
2309
|
const _c = _1;
|
|
2837
2310
|
return ff_compiler_Syntax.EField(_c.at_, _c.newtype_, record_, _c.field_)
|
|
2838
|
-
return
|
|
2839
2311
|
}
|
|
2840
2312
|
}
|
|
2841
2313
|
})), (() => {
|
|
@@ -2848,31 +2320,24 @@ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Sy
|
|
|
2848
2320
|
return
|
|
2849
2321
|
}
|
|
2850
2322
|
}
|
|
2851
|
-
}
|
|
2852
|
-
{
|
|
2853
|
-
const t_ = _1;
|
|
2854
2323
|
if(_1.TConstructor) {
|
|
2324
|
+
const t_ = _1;
|
|
2855
2325
|
const name_ = _1.name_;
|
|
2856
2326
|
const typeArguments_ = _1.generics_;
|
|
2857
2327
|
const memberPrefix_ = (name_ + "_");
|
|
2858
2328
|
const memberName_ = (memberPrefix_ + e_.field_);
|
|
2859
2329
|
{
|
|
2860
2330
|
const _1 = ff_compiler_Inference.Inference_lookup(self_, environment_, expected_, e_.at_, memberName_, typeArguments_, ff_core_Option.None());
|
|
2861
|
-
{
|
|
2862
2331
|
if(_1.Some) {
|
|
2863
2332
|
const instantiated_ = _1.value_;
|
|
2864
|
-
|
|
2865
|
-
if(_guard1) {
|
|
2333
|
+
if((!instantiated_.scheme_.isVariable_)) {
|
|
2866
2334
|
const signature_ = (((_c) => {
|
|
2867
2335
|
return ff_compiler_Syntax.Signature(_c.at_, _c.name_, _c.member_, _c.generics_, _c.constraints_, ff_core_List.List_dropFirst(instantiated_.scheme_.signature_.parameters_, 1), _c.returnType_, _c.effect_)
|
|
2868
2336
|
}))(instantiated_.scheme_.signature_);
|
|
2869
2337
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, recordType_, ff_core_List.List_grab(instantiated_.scheme_.signature_.parameters_, 0).valueType_);
|
|
2870
2338
|
return ff_compiler_Inference.Inference_inferEtaExpansion(self_, environment_, expected_, e_.at_, signature_, term_)
|
|
2871
|
-
return
|
|
2872
2339
|
}
|
|
2873
2340
|
}
|
|
2874
|
-
}
|
|
2875
|
-
{
|
|
2876
2341
|
if(_1.Some) {
|
|
2877
2342
|
const instantiated_ = _1.value_;
|
|
2878
2343
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, instantiated_.scheme_.signature_.returnType_);
|
|
@@ -2881,43 +2346,26 @@ const _1 = e_;
|
|
|
2881
2346
|
{
|
|
2882
2347
|
const _c = _1;
|
|
2883
2348
|
return ff_compiler_Syntax.EField(_c.at_, instantiated_.scheme_.isNewtype_, record_, _c.field_)
|
|
2884
|
-
return
|
|
2885
2349
|
}
|
|
2886
2350
|
}
|
|
2887
2351
|
return
|
|
2888
2352
|
}
|
|
2889
|
-
}
|
|
2890
|
-
{
|
|
2891
2353
|
if(_1.None) {
|
|
2892
2354
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(e_.at_, ((("No such field " + e_.field_) + " on type: ") + ff_compiler_Syntax.Type_show(t_, []))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
2893
|
-
return
|
|
2894
|
-
}
|
|
2895
2355
|
}
|
|
2896
2356
|
}
|
|
2897
2357
|
return
|
|
2898
2358
|
}
|
|
2899
|
-
|
|
2900
|
-
{
|
|
2901
|
-
if(_1.TVariable) {
|
|
2902
|
-
const _guard1 = ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_);
|
|
2903
|
-
if(_guard1) {
|
|
2359
|
+
if(_1.TVariable && ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
|
|
2904
2360
|
return term_
|
|
2905
|
-
return
|
|
2906
|
-
}
|
|
2907
|
-
}
|
|
2908
2361
|
}
|
|
2909
|
-
{
|
|
2910
2362
|
if(_1.TVariable) {
|
|
2911
2363
|
const index_ = _1.index_;
|
|
2912
2364
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(e_.at_, ((("No such field " + e_.field_) + " on unknown type: $") + index_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
2913
|
-
return
|
|
2914
|
-
}
|
|
2915
2365
|
}
|
|
2916
2366
|
}
|
|
2917
2367
|
return
|
|
2918
2368
|
}
|
|
2919
|
-
}
|
|
2920
|
-
{
|
|
2921
2369
|
if(_1.EWildcard) {
|
|
2922
2370
|
const e_ = _1;
|
|
2923
2371
|
return ff_core_Option.Option_grab(ff_core_Option.Option_map(ff_compiler_Inference.Inference_lookup(self_, environment_, expected_, e_.at_, ("_w" + e_.index_), [], ff_core_Option.None()), ((instantiated_) => {
|
|
@@ -2926,8 +2374,6 @@ return term_
|
|
|
2926
2374
|
})))
|
|
2927
2375
|
return
|
|
2928
2376
|
}
|
|
2929
|
-
}
|
|
2930
|
-
{
|
|
2931
2377
|
if(_1.EList) {
|
|
2932
2378
|
const at_ = _1.at_;
|
|
2933
2379
|
const t_ = _1.elementType_;
|
|
@@ -2946,8 +2392,6 @@ return
|
|
|
2946
2392
|
})))
|
|
2947
2393
|
return
|
|
2948
2394
|
}
|
|
2949
|
-
}
|
|
2950
|
-
{
|
|
2951
2395
|
if(_1.ESequential) {
|
|
2952
2396
|
const at_ = _1.at_;
|
|
2953
2397
|
const before_ = _1.before_;
|
|
@@ -2958,12 +2402,10 @@ ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.InferSequen
|
|
|
2958
2402
|
const newExpected_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, at_);
|
|
2959
2403
|
{
|
|
2960
2404
|
const _1 = before_;
|
|
2961
|
-
{
|
|
2962
|
-
if(_1.EPipe) {
|
|
2405
|
+
if(_1.EPipe && _1.function_.ELambda) {
|
|
2963
2406
|
const at1_ = _1.at_;
|
|
2964
2407
|
const value_ = _1.value_;
|
|
2965
2408
|
const effect1_ = _1.effect_;
|
|
2966
|
-
if(_1.function_.ELambda) {
|
|
2967
2409
|
const at2_ = _1.function_.at_;
|
|
2968
2410
|
const at3_ = _1.function_.lambda_.at_;
|
|
2969
2411
|
const effect3_ = _1.function_.lambda_.effect_;
|
|
@@ -2975,42 +2417,30 @@ const _1 = case_;
|
|
|
2975
2417
|
{
|
|
2976
2418
|
const _c = _1;
|
|
2977
2419
|
return ff_compiler_Syntax.MatchCase(_c.at_, _c.patterns_, _c.guards_, ff_compiler_Syntax.ESequential(case_.at_, case_.body_, e_))
|
|
2978
|
-
return
|
|
2979
2420
|
}
|
|
2980
2421
|
}
|
|
2981
2422
|
}));
|
|
2982
2423
|
const newPipe_ = ff_compiler_Syntax.EPipe(at1_, value_, effect1_, ff_compiler_Syntax.ELambda(at2_, ff_compiler_Syntax.Lambda(at3_, effect3_, newCases_)));
|
|
2983
2424
|
{
|
|
2984
2425
|
const _1 = after_;
|
|
2985
|
-
{
|
|
2986
|
-
if(_1.EVariant) {
|
|
2426
|
+
if(_1.EVariant && _1.name_ === "ff:core/Unit.Unit") {
|
|
2987
2427
|
const at_ = _1.at_;
|
|
2988
|
-
if(_1.name_ === "ff:core/Unit.Unit") {
|
|
2989
2428
|
const unitType_ = ff_compiler_Syntax.TConstructor(at_, ff_compiler_Inference.core_("Unit"), []);
|
|
2990
2429
|
ff_compiler_Unification.Unification_unify(self_.unification_, at_, expected_, unitType_);
|
|
2991
2430
|
return ff_compiler_Inference.Inference_inferTerm(self_, environment_, newExpected_, newPipe_)
|
|
2992
|
-
return
|
|
2993
|
-
}
|
|
2994
|
-
}
|
|
2995
2431
|
}
|
|
2996
2432
|
{
|
|
2997
2433
|
return ff_compiler_Syntax.ESequential(at_, ff_compiler_Inference.Inference_inferTerm(self_, environment_, newExpected_, newPipe_), ff_compiler_Inference.Inference_inferTerm(self_, environment_, expected_, after_))
|
|
2998
|
-
return
|
|
2999
2434
|
}
|
|
3000
2435
|
}
|
|
3001
2436
|
return
|
|
3002
2437
|
}
|
|
3003
|
-
}
|
|
3004
|
-
}
|
|
3005
2438
|
{
|
|
3006
2439
|
return ff_compiler_Syntax.ESequential(at_, ff_compiler_Inference.Inference_inferTerm(self_, environment_, newExpected_, before_), ff_compiler_Inference.Inference_inferTerm(self_, environment_, expected_, after_))
|
|
3007
|
-
return
|
|
3008
2440
|
}
|
|
3009
2441
|
}
|
|
3010
2442
|
return
|
|
3011
2443
|
}
|
|
3012
|
-
}
|
|
3013
|
-
{
|
|
3014
2444
|
if(_1.ELet) {
|
|
3015
2445
|
const e_ = _1;
|
|
3016
2446
|
const noEffect_ = ff_compiler_Syntax.TConstructor(e_.at_, "ff:core/Nothing.Nothing", []);
|
|
@@ -3023,64 +2453,29 @@ const _1 = e_;
|
|
|
3023
2453
|
{
|
|
3024
2454
|
const _c = _1;
|
|
3025
2455
|
return ff_compiler_Syntax.ELet(_c.at_, _c.mutable_, _c.name_, _c.valueType_, ff_compiler_Inference.Inference_inferTerm(self_, environment_, e_.valueType_, e_.value_), ff_compiler_Inference.Inference_inferTerm(self_, environment2_, expected_, e_.body_))
|
|
3026
|
-
return
|
|
3027
2456
|
}
|
|
3028
2457
|
}
|
|
3029
2458
|
return
|
|
3030
2459
|
}
|
|
3031
|
-
}
|
|
3032
|
-
{
|
|
3033
2460
|
if(_1.ELambda) {
|
|
3034
2461
|
const at_ = _1.at_;
|
|
3035
2462
|
const l_ = _1.lambda_;
|
|
3036
2463
|
do {
|
|
3037
2464
|
const _1 = l_.cases_;
|
|
3038
|
-
{
|
|
3039
|
-
if(_1.length > 0) {
|
|
3040
|
-
if(_1[0].patterns_.length === 0) {
|
|
3041
|
-
if(_1[0].guards_.length === 0) {
|
|
3042
|
-
if(_1[0].body_.EVariable) {
|
|
2465
|
+
if(_1.length === 1 && _1[0].patterns_.length === 0 && _1[0].guards_.length === 0 && _1[0].body_.EVariable && _1[0].body_.name_ === "") {
|
|
3043
2466
|
const insideAt_ = _1[0].body_.at_;
|
|
3044
|
-
if(
|
|
3045
|
-
if(_1.length === 1) {
|
|
3046
|
-
const _guard1 = ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, insideAt_);
|
|
3047
|
-
if(_guard1) {
|
|
2467
|
+
if(ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, insideAt_)) {
|
|
3048
2468
|
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.InferLambdaStartHook(self_.unification_, environment_, expected_))
|
|
3049
2469
|
break
|
|
3050
2470
|
}
|
|
3051
2471
|
}
|
|
3052
|
-
|
|
3053
|
-
}
|
|
3054
|
-
}
|
|
3055
|
-
}
|
|
3056
|
-
}
|
|
3057
|
-
}
|
|
3058
|
-
{
|
|
3059
|
-
if(_1.length > 0) {
|
|
3060
|
-
if(_1[0].patterns_.length === 0) {
|
|
3061
|
-
if(_1[0].guards_.length === 0) {
|
|
3062
|
-
if(_1[0].body_.ESequential) {
|
|
3063
|
-
if(_1[0].body_.before_.EVariable) {
|
|
2472
|
+
if(_1.length === 1 && _1[0].patterns_.length === 0 && _1[0].guards_.length === 0 && _1[0].body_.ESequential && _1[0].body_.before_.EVariable && _1[0].body_.before_.name_ === "" && _1[0].body_.after_.EVariant && _1[0].body_.after_.name_ === "ff:core/Unit.Unit") {
|
|
3064
2473
|
const insideAt_ = _1[0].body_.before_.at_;
|
|
3065
|
-
if(
|
|
3066
|
-
if(_1[0].body_.after_.EVariant) {
|
|
3067
|
-
if(_1[0].body_.after_.name_ === "ff:core/Unit.Unit") {
|
|
3068
|
-
if(_1.length === 1) {
|
|
3069
|
-
const _guard1 = ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, insideAt_);
|
|
3070
|
-
if(_guard1) {
|
|
2474
|
+
if(ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, insideAt_)) {
|
|
3071
2475
|
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.InferLambdaStartHook(self_.unification_, environment_, expected_))
|
|
3072
2476
|
break
|
|
3073
2477
|
}
|
|
3074
2478
|
}
|
|
3075
|
-
}
|
|
3076
|
-
}
|
|
3077
|
-
}
|
|
3078
|
-
}
|
|
3079
|
-
}
|
|
3080
|
-
}
|
|
3081
|
-
}
|
|
3082
|
-
}
|
|
3083
|
-
}
|
|
3084
2479
|
{
|
|
3085
2480
|
|
|
3086
2481
|
break
|
|
@@ -3088,10 +2483,7 @@ break
|
|
|
3088
2483
|
} while(false);
|
|
3089
2484
|
const lambda_ = ff_compiler_Inference.Inference_inferLambda(self_, environment_, expected_, l_);
|
|
3090
2485
|
return ff_compiler_Syntax.ELambda(at_, lambda_)
|
|
3091
|
-
return
|
|
3092
|
-
}
|
|
3093
2486
|
}
|
|
3094
|
-
{
|
|
3095
2487
|
if(_1.EVariant) {
|
|
3096
2488
|
const e_ = _1;
|
|
3097
2489
|
const instantiated_ = ff_core_Option.Option_else(ff_compiler_Inference.Inference_lookup(self_, environment_, expected_, e_.at_, e_.name_, e_.typeArguments_, e_.arguments_), (() => {
|
|
@@ -3113,8 +2505,6 @@ return
|
|
|
3113
2505
|
}
|
|
3114
2506
|
return
|
|
3115
2507
|
}
|
|
3116
|
-
}
|
|
3117
|
-
{
|
|
3118
2508
|
if(_1.EVariantIs) {
|
|
3119
2509
|
const e_ = _1;
|
|
3120
2510
|
const instantiated_ = ff_core_Option.Option_else(ff_compiler_Inference.Inference_lookup(self_, environment_, expected_, e_.at_, e_.name_, e_.typeArguments_, ff_core_Option.None()), (() => {
|
|
@@ -3142,8 +2532,6 @@ return
|
|
|
3142
2532
|
}
|
|
3143
2533
|
return
|
|
3144
2534
|
}
|
|
3145
|
-
}
|
|
3146
|
-
{
|
|
3147
2535
|
if(_1.ECopy) {
|
|
3148
2536
|
const e_ = _1;
|
|
3149
2537
|
const scheme_ = ff_core_Option.Option_else(ff_compiler_Inference.Inference_lookup(self_, environment_, expected_, e_.at_, e_.name_, [], ff_core_Option.None()), (() => {
|
|
@@ -3170,7 +2558,6 @@ const _1 = f_;
|
|
|
3170
2558
|
{
|
|
3171
2559
|
const _c = _1;
|
|
3172
2560
|
return ff_compiler_Syntax.Argument(_c.at_, ff_core_Option.Some(f_.name_), _c.value_)
|
|
3173
|
-
return
|
|
3174
2561
|
}
|
|
3175
2562
|
}
|
|
3176
2563
|
}));
|
|
@@ -3193,7 +2580,6 @@ const at_ = _1.at_;
|
|
|
3193
2580
|
const name_ = _1.name_;
|
|
3194
2581
|
const value_ = _1.value_;
|
|
3195
2582
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, ("Unknown parameter: " + name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
3196
|
-
return
|
|
3197
2583
|
}
|
|
3198
2584
|
}));
|
|
3199
2585
|
const arguments_ = ff_core_List.List_map(parameterNames_, ((name_) => {
|
|
@@ -3204,7 +2590,6 @@ return (_w1.name_ === name_)
|
|
|
3204
2590
|
const at_ = _1.at_;
|
|
3205
2591
|
const value_ = _1.value_;
|
|
3206
2592
|
return ff_compiler_Syntax.Argument(at_, ff_core_Option.Some(name_), value_)
|
|
3207
|
-
return
|
|
3208
2593
|
}
|
|
3209
2594
|
})), (() => {
|
|
3210
2595
|
const at_ = (((_c) => {
|
|
@@ -3217,10 +2602,7 @@ const body_ = ff_compiler_Syntax.EVariant(e_.at_, e_.name_, [], ff_core_Option.S
|
|
|
3217
2602
|
const effect_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, e_.at_);
|
|
3218
2603
|
const e1_ = ff_compiler_Syntax.EPipe(e_.at_, e_.record_, effect_, ff_compiler_Syntax.ELambda(e_.at_, ff_compiler_Syntax.Lambda(e_.at_, effect_, [ff_compiler_Syntax.MatchCase(e_.at_, [ff_compiler_Syntax.PVariable(e_.at_, ff_core_Option.Some("_c"))], [], body_)])));
|
|
3219
2604
|
return ff_compiler_Inference.Inference_inferTerm(self_, environment_, expected_, e1_)
|
|
3220
|
-
return
|
|
3221
|
-
}
|
|
3222
2605
|
}
|
|
3223
|
-
{
|
|
3224
2606
|
if(_1.EPipe) {
|
|
3225
2607
|
const e_ = _1;
|
|
3226
2608
|
const valueType_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, e_.at_);
|
|
@@ -3233,47 +2615,37 @@ const _1 = e_;
|
|
|
3233
2615
|
{
|
|
3234
2616
|
const _c = _1;
|
|
3235
2617
|
return ff_compiler_Syntax.EPipe(_c.at_, value_, _c.effect_, function_)
|
|
3236
|
-
return
|
|
3237
2618
|
}
|
|
3238
2619
|
}
|
|
3239
2620
|
return
|
|
3240
2621
|
}
|
|
3241
|
-
}
|
|
3242
|
-
{
|
|
3243
2622
|
if(_1.ECall) {
|
|
3244
2623
|
const e_ = _1;
|
|
3245
2624
|
if((ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_) && (((_1) => {
|
|
3246
|
-
{
|
|
3247
2625
|
if(_1.StaticCall) {
|
|
3248
2626
|
return true
|
|
3249
|
-
return
|
|
3250
|
-
}
|
|
3251
2627
|
}
|
|
3252
2628
|
{
|
|
3253
2629
|
return false
|
|
3254
|
-
return
|
|
3255
2630
|
}
|
|
3256
2631
|
}))(e_.target_))) {
|
|
3257
2632
|
return term_
|
|
3258
2633
|
} else {
|
|
3259
2634
|
const call_ = (((_1) => {
|
|
3260
|
-
{
|
|
3261
2635
|
if(_1.DynamicCall) {
|
|
3262
2636
|
const call_ = _1;
|
|
3263
|
-
return
|
|
3264
|
-
|
|
2637
|
+
return {
|
|
2638
|
+
function_: call_.function_,
|
|
2639
|
+
tailCall_: call_.tailCall_
|
|
3265
2640
|
}
|
|
2641
|
+
return
|
|
3266
2642
|
}
|
|
3267
|
-
{
|
|
3268
2643
|
if(_1.StaticCall) {
|
|
3269
2644
|
return ff_compiler_Inference.fail_(e_.at_, "Internal error: Static calls not expected in the Inference phase")
|
|
3270
|
-
return
|
|
3271
|
-
}
|
|
3272
2645
|
}
|
|
3273
2646
|
}))(e_.target_);
|
|
3274
2647
|
{
|
|
3275
2648
|
const _1 = call_.function_;
|
|
3276
|
-
{
|
|
3277
2649
|
if(_1.EVariable) {
|
|
3278
2650
|
const variableAt_ = _1.at_;
|
|
3279
2651
|
const x_ = _1.name_;
|
|
@@ -3284,7 +2656,6 @@ return ff_compiler_Inference.Inference_inferOperator(self_, environment_, expect
|
|
|
3284
2656
|
} else {
|
|
3285
2657
|
{
|
|
3286
2658
|
const _1 = ff_compiler_Inference.Inference_lookup(self_, environment_, expected_, e_.at_, x_, e_.typeArguments_, ff_core_Option.Some(e_.arguments_));
|
|
3287
|
-
{
|
|
3288
2659
|
if(_1.Some) {
|
|
3289
2660
|
const instantiated_ = _1.value_;
|
|
3290
2661
|
if(instantiated_.scheme_.isVariable_) {
|
|
@@ -3295,19 +2666,13 @@ return ff_compiler_Inference.Inference_inferFunctionCall(self_, environment_, ex
|
|
|
3295
2666
|
}
|
|
3296
2667
|
return
|
|
3297
2668
|
}
|
|
3298
|
-
}
|
|
3299
|
-
{
|
|
3300
2669
|
if(_1.None) {
|
|
3301
2670
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(variableAt_, ("No such function: " + x_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
3302
|
-
return
|
|
3303
|
-
}
|
|
3304
2671
|
}
|
|
3305
2672
|
}
|
|
3306
2673
|
}
|
|
3307
2674
|
return
|
|
3308
2675
|
}
|
|
3309
|
-
}
|
|
3310
|
-
{
|
|
3311
2676
|
if(_1.EField) {
|
|
3312
2677
|
const f_ = _1;
|
|
3313
2678
|
const recordType_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, f_.at_);
|
|
@@ -3326,71 +2691,46 @@ return ff_compiler_Syntax.EField(_c.at_, _c.newtype_, record_, _c.field_)
|
|
|
3326
2691
|
}))(e_);
|
|
3327
2692
|
{
|
|
3328
2693
|
const _1 = ff_compiler_Unification.Unification_substitute(self_.unification_, recordType_);
|
|
3329
|
-
{
|
|
3330
|
-
const t_ = _1;
|
|
3331
2694
|
if(_1.TConstructor) {
|
|
2695
|
+
const t_ = _1;
|
|
3332
2696
|
const name_ = _1.name_;
|
|
3333
2697
|
const methodName_ = ((name_ + "_") + f_.field_);
|
|
3334
2698
|
const arguments_ = [ff_compiler_Syntax.Argument(f_.record_.at_, ff_core_Option.None(), f_.record_), ...e_.arguments_];
|
|
3335
2699
|
{
|
|
3336
2700
|
const _1 = ff_compiler_Inference.Inference_lookup(self_, environment_, expected_, f_.at_, methodName_, [], ff_core_Option.Some(arguments_));
|
|
3337
|
-
{
|
|
3338
2701
|
if(_1.Some) {
|
|
3339
2702
|
const instantiated_ = _1.value_;
|
|
3340
|
-
|
|
3341
|
-
if(_guard1) {
|
|
2703
|
+
if((!instantiated_.scheme_.isVariable_)) {
|
|
3342
2704
|
return ff_compiler_Inference.Inference_inferMethodCall(self_, environment_, expected_, instantiated_.scheme_.signature_, instantiated_.typeArguments_, e2_, record_, recordType_, methodName_)
|
|
3343
|
-
return
|
|
3344
|
-
}
|
|
3345
2705
|
}
|
|
3346
2706
|
}
|
|
3347
|
-
{
|
|
3348
2707
|
if(_1.Some) {
|
|
3349
2708
|
const instantiated_ = _1.value_;
|
|
3350
2709
|
return ff_compiler_Inference.Inference_inferLambdaCall(self_, environment_, expected_, e2_)
|
|
3351
|
-
return
|
|
3352
|
-
}
|
|
3353
2710
|
}
|
|
3354
|
-
{
|
|
3355
2711
|
if(_1.None) {
|
|
3356
2712
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(f_.at_, ((("No such field " + f_.field_) + " on type: ") + ff_compiler_Syntax.Type_show(t_, []))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
3357
|
-
return
|
|
3358
|
-
}
|
|
3359
2713
|
}
|
|
3360
2714
|
}
|
|
3361
2715
|
return
|
|
3362
2716
|
}
|
|
3363
|
-
|
|
3364
|
-
{
|
|
3365
|
-
if(_1.TVariable) {
|
|
3366
|
-
const _guard1 = ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_);
|
|
3367
|
-
if(_guard1) {
|
|
2717
|
+
if(_1.TVariable && ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
|
|
3368
2718
|
return ff_compiler_Inference.Inference_inferLambdaCall(self_, environment_, expected_, e2_)
|
|
3369
|
-
return
|
|
3370
2719
|
}
|
|
3371
|
-
}
|
|
3372
|
-
}
|
|
3373
|
-
{
|
|
3374
2720
|
if(_1.TVariable) {
|
|
3375
2721
|
const index_ = _1.index_;
|
|
3376
2722
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(f_.at_, ((("No such field " + f_.field_) + " on unknown type: $") + index_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
3377
|
-
return
|
|
3378
|
-
}
|
|
3379
2723
|
}
|
|
3380
2724
|
}
|
|
3381
2725
|
return
|
|
3382
2726
|
}
|
|
3383
|
-
}
|
|
3384
2727
|
{
|
|
3385
2728
|
return ff_compiler_Inference.Inference_inferLambdaCall(self_, environment_, expected_, term_)
|
|
3386
|
-
return
|
|
3387
2729
|
}
|
|
3388
2730
|
}
|
|
3389
2731
|
}
|
|
3390
2732
|
return
|
|
3391
2733
|
}
|
|
3392
|
-
}
|
|
3393
|
-
{
|
|
3394
2734
|
if(_1.ERecord) {
|
|
3395
2735
|
const e_ = _1;
|
|
3396
2736
|
const fields_ = ff_core_List.List_sortBy(e_.fields_, ((_w1) => {
|
|
@@ -3412,7 +2752,6 @@ const _1 = field_;
|
|
|
3412
2752
|
{
|
|
3413
2753
|
const _c = _1;
|
|
3414
2754
|
return ff_compiler_Syntax.Field(_c.at_, _c.name_, ff_compiler_Inference.Inference_inferTerm(self_, environment_, t_, field_.value_))
|
|
3415
|
-
return
|
|
3416
2755
|
}
|
|
3417
2756
|
}
|
|
3418
2757
|
return
|
|
@@ -3423,13 +2762,10 @@ const _1 = e_;
|
|
|
3423
2762
|
{
|
|
3424
2763
|
const _c = _1;
|
|
3425
2764
|
return ff_compiler_Syntax.ERecord(_c.at_, newFields_)
|
|
3426
|
-
return
|
|
3427
2765
|
}
|
|
3428
2766
|
}
|
|
3429
2767
|
return
|
|
3430
2768
|
}
|
|
3431
|
-
}
|
|
3432
|
-
{
|
|
3433
2769
|
if(_1.EFunctions) {
|
|
3434
2770
|
const at_ = _1.at_;
|
|
3435
2771
|
const functions_ = _1.functions_;
|
|
@@ -3446,10 +2782,7 @@ return ff_compiler_Inference.Inference_inferFunctionDefinition(self_, environmen
|
|
|
3446
2782
|
}));
|
|
3447
2783
|
const newBody_ = ff_compiler_Inference.Inference_inferTerm(self_, environment2_, expected_, body_);
|
|
3448
2784
|
return ff_compiler_Syntax.EFunctions(at_, newFunctions_, newBody_)
|
|
3449
|
-
return
|
|
3450
|
-
}
|
|
3451
2785
|
}
|
|
3452
|
-
{
|
|
3453
2786
|
if(_1.EAssign) {
|
|
3454
2787
|
const e_ = _1;
|
|
3455
2788
|
return ff_core_Option.Option_else(ff_core_Option.Option_map(ff_compiler_Inference.Inference_lookup(self_, environment_, expected_, e_.at_, e_.variable_, [], ff_core_Option.None()), ((instantiated_) => {
|
|
@@ -3460,7 +2793,6 @@ const _1 = e_;
|
|
|
3460
2793
|
{
|
|
3461
2794
|
const _c = _1;
|
|
3462
2795
|
return ff_compiler_Syntax.EAssign(_c.at_, _c.operator_, _c.variable_, value_)
|
|
3463
|
-
return
|
|
3464
2796
|
}
|
|
3465
2797
|
}
|
|
3466
2798
|
} else {
|
|
@@ -3471,91 +2803,63 @@ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Sy
|
|
|
3471
2803
|
}))
|
|
3472
2804
|
return
|
|
3473
2805
|
}
|
|
3474
|
-
}
|
|
3475
|
-
{
|
|
3476
2806
|
if(_1.EAssignField) {
|
|
3477
2807
|
const e_ = _1;
|
|
3478
2808
|
const recordType_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, e_.at_);
|
|
3479
2809
|
const record_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, recordType_, e_.record_);
|
|
3480
2810
|
{
|
|
3481
2811
|
const _1 = ff_compiler_Unification.Unification_substitute(self_.unification_, recordType_);
|
|
3482
|
-
{
|
|
3483
|
-
const t_ = _1;
|
|
3484
2812
|
if(_1.TConstructor) {
|
|
2813
|
+
const t_ = _1;
|
|
3485
2814
|
const name_ = _1.name_;
|
|
3486
2815
|
const typeArguments_ = _1.generics_;
|
|
3487
|
-
|
|
3488
|
-
if(_guard1) {
|
|
2816
|
+
if(ff_core_String.String_startsWith(name_, "Record$", 0)) {
|
|
3489
2817
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(e_.at_, ("Can't assign fields of anonymous records: " + e_.field_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
3490
|
-
return
|
|
3491
2818
|
}
|
|
3492
2819
|
}
|
|
3493
|
-
}
|
|
3494
|
-
{
|
|
3495
|
-
const t_ = _1;
|
|
3496
2820
|
if(_1.TConstructor) {
|
|
2821
|
+
const t_ = _1;
|
|
3497
2822
|
const name_ = _1.name_;
|
|
3498
2823
|
const typeArguments_ = _1.generics_;
|
|
3499
2824
|
const methodName_ = ((name_ + "_") + e_.field_);
|
|
3500
2825
|
{
|
|
3501
2826
|
const _1 = ff_compiler_Inference.Inference_lookup(self_, environment_, expected_, e_.at_, methodName_, typeArguments_, ff_core_Option.None());
|
|
3502
|
-
{
|
|
3503
2827
|
if(_1.Some) {
|
|
3504
2828
|
const instantiated_ = _1.value_;
|
|
3505
|
-
|
|
3506
|
-
if(_guard1) {
|
|
2829
|
+
if((instantiated_.scheme_.isMutable_ || ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_))) {
|
|
3507
2830
|
const value_ = ff_compiler_Inference.Inference_inferAssignment(self_, environment_, expected_, e_.at_, e_.operator_, e_.value_, instantiated_.scheme_.signature_);
|
|
3508
2831
|
{
|
|
3509
2832
|
const _1 = e_;
|
|
3510
2833
|
{
|
|
3511
2834
|
const _c = _1;
|
|
3512
2835
|
return ff_compiler_Syntax.EAssignField(_c.at_, _c.operator_, record_, _c.field_, value_)
|
|
3513
|
-
return
|
|
3514
2836
|
}
|
|
3515
2837
|
}
|
|
3516
2838
|
return
|
|
3517
2839
|
}
|
|
3518
2840
|
}
|
|
3519
|
-
}
|
|
3520
|
-
{
|
|
3521
2841
|
if(_1.Some) {
|
|
3522
2842
|
const instantiated_ = _1.value_;
|
|
3523
2843
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(e_.at_, ((("Can't assign an immutable field " + e_.field_) + " on type: ") + ff_compiler_Syntax.Type_show(t_, []))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
3524
|
-
return
|
|
3525
|
-
}
|
|
3526
2844
|
}
|
|
3527
|
-
{
|
|
3528
2845
|
if(_1.None) {
|
|
3529
2846
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(e_.at_, ((("No such field " + e_.field_) + " on type: ") + ff_compiler_Syntax.Type_show(t_, []))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
3530
|
-
return
|
|
3531
|
-
}
|
|
3532
2847
|
}
|
|
3533
2848
|
}
|
|
3534
2849
|
return
|
|
3535
2850
|
}
|
|
3536
|
-
|
|
3537
|
-
{
|
|
3538
|
-
if(_1.TVariable) {
|
|
3539
|
-
const _guard1 = ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_);
|
|
3540
|
-
if(_guard1) {
|
|
2851
|
+
if(_1.TVariable && ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
|
|
3541
2852
|
return term_
|
|
3542
|
-
return
|
|
3543
|
-
}
|
|
3544
|
-
}
|
|
3545
2853
|
}
|
|
3546
|
-
{
|
|
3547
2854
|
if(_1.TVariable) {
|
|
3548
2855
|
const index_ = _1.index_;
|
|
3549
2856
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(e_.at_, ((("No such field " + e_.field_) + " on unknown type: $") + index_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
3550
|
-
return
|
|
3551
|
-
}
|
|
3552
2857
|
}
|
|
3553
2858
|
}
|
|
3554
2859
|
return
|
|
3555
2860
|
}
|
|
3556
2861
|
}
|
|
3557
2862
|
}
|
|
3558
|
-
}
|
|
3559
2863
|
|
|
3560
2864
|
export async function Inference_inferAssignment$(self_, environment_, expected_, at_, operator_, value_, signature_, $task) {
|
|
3561
2865
|
const t_ = signature_.returnType_;
|
|
@@ -3570,32 +2874,17 @@ return newValue_
|
|
|
3570
2874
|
}
|
|
3571
2875
|
|
|
3572
2876
|
export async function Inference_inferMethodCall$(self_, environment_, expected_, signature_, instantiation_, term_, record_, recordType_, name_, $task) {
|
|
3573
|
-
const e_ = (((_1) => {
|
|
3574
2877
|
{
|
|
2878
|
+
const _1 = term_;
|
|
3575
2879
|
if(_1.ECall) {
|
|
3576
2880
|
const e_ = _1;
|
|
3577
|
-
|
|
3578
|
-
return
|
|
3579
|
-
}
|
|
3580
|
-
}
|
|
3581
|
-
{
|
|
3582
|
-
return ff_compiler_Inference.fail_(term_.at_, "Call expected")
|
|
3583
|
-
return
|
|
3584
|
-
}
|
|
3585
|
-
}))(term_);
|
|
3586
|
-
const call_ = (((_1) => {
|
|
3587
|
-
{
|
|
2881
|
+
const tailCall_ = (((_1) => {
|
|
3588
2882
|
if(_1.DynamicCall) {
|
|
3589
2883
|
const call_ = _1;
|
|
3590
|
-
return call_
|
|
3591
|
-
return
|
|
3592
|
-
}
|
|
2884
|
+
return call_.tailCall_
|
|
3593
2885
|
}
|
|
3594
|
-
{
|
|
3595
2886
|
if(_1.StaticCall) {
|
|
3596
2887
|
return ff_compiler_Inference.fail_(e_.at_, "Internal error: Static calls not expected in inferMethodCall")
|
|
3597
|
-
return
|
|
3598
|
-
}
|
|
3599
2888
|
}
|
|
3600
2889
|
}))(e_.target_);
|
|
3601
2890
|
const selfParameter_ = ff_core_List.List_grabFirst(signature_.parameters_);
|
|
@@ -3608,41 +2897,32 @@ ff_compiler_Unification.Unification_affect(self_.unification_, term_.at_, signat
|
|
|
3608
2897
|
const _1 = e_;
|
|
3609
2898
|
{
|
|
3610
2899
|
const _c = _1;
|
|
3611
|
-
return ff_compiler_Syntax.ECall(_c.at_, ff_compiler_Syntax.StaticCall(name_,
|
|
2900
|
+
return ff_compiler_Syntax.ECall(_c.at_, ff_compiler_Syntax.StaticCall(name_, tailCall_, false), signature_.effect_, ff_core_List.List_map(instantiation_, ((_w1) => {
|
|
3612
2901
|
return _w1.second_
|
|
3613
2902
|
})), [selfArgument_, ...arguments_], _c.dictionaries_)
|
|
3614
2903
|
return
|
|
3615
2904
|
}
|
|
3616
2905
|
}
|
|
3617
|
-
}
|
|
3618
|
-
|
|
3619
|
-
export async function Inference_inferFunctionCall$(self_, environment_, expected_, signature_, instanceCall_, instantiation_, term_, name_, $task) {
|
|
3620
|
-
const e_ = (((_1) => {
|
|
3621
|
-
{
|
|
3622
|
-
if(_1.ECall) {
|
|
3623
|
-
const e_ = _1;
|
|
3624
|
-
return e_
|
|
3625
2906
|
return
|
|
3626
2907
|
}
|
|
3627
|
-
}
|
|
3628
2908
|
{
|
|
3629
2909
|
return ff_compiler_Inference.fail_(term_.at_, "Call expected")
|
|
3630
|
-
return
|
|
3631
2910
|
}
|
|
3632
|
-
}
|
|
3633
|
-
|
|
2911
|
+
}
|
|
2912
|
+
}
|
|
2913
|
+
|
|
2914
|
+
export async function Inference_inferFunctionCall$(self_, environment_, expected_, signature_, instanceCall_, instantiation_, term_, name_, $task) {
|
|
3634
2915
|
{
|
|
2916
|
+
const _1 = term_;
|
|
2917
|
+
if(_1.ECall) {
|
|
2918
|
+
const e_ = _1;
|
|
2919
|
+
const tailCall_ = (((_1) => {
|
|
3635
2920
|
if(_1.DynamicCall) {
|
|
3636
2921
|
const call_ = _1;
|
|
3637
|
-
return call_
|
|
3638
|
-
return
|
|
2922
|
+
return call_.tailCall_
|
|
3639
2923
|
}
|
|
3640
|
-
}
|
|
3641
|
-
{
|
|
3642
2924
|
if(_1.StaticCall) {
|
|
3643
2925
|
return ff_compiler_Inference.fail_(e_.at_, "Internal error: Static calls not expected in inferFunctionCall")
|
|
3644
|
-
return
|
|
3645
|
-
}
|
|
3646
2926
|
}
|
|
3647
2927
|
}))(e_.target_);
|
|
3648
2928
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, signature_.returnType_);
|
|
@@ -3652,50 +2932,41 @@ ff_compiler_Unification.Unification_affect(self_.unification_, term_.at_, signat
|
|
|
3652
2932
|
const _1 = e_;
|
|
3653
2933
|
{
|
|
3654
2934
|
const _c = _1;
|
|
3655
|
-
return ff_compiler_Syntax.ECall(_c.at_, ff_compiler_Syntax.StaticCall(name_,
|
|
2935
|
+
return ff_compiler_Syntax.ECall(_c.at_, ff_compiler_Syntax.StaticCall(name_, tailCall_, instanceCall_), signature_.effect_, ff_core_List.List_map(instantiation_, ((_w1) => {
|
|
3656
2936
|
return _w1.second_
|
|
3657
2937
|
})), arguments_, _c.dictionaries_)
|
|
3658
2938
|
return
|
|
3659
2939
|
}
|
|
3660
2940
|
}
|
|
2941
|
+
return
|
|
2942
|
+
}
|
|
2943
|
+
{
|
|
2944
|
+
return ff_compiler_Inference.fail_(term_.at_, "Call expected")
|
|
2945
|
+
}
|
|
2946
|
+
}
|
|
3661
2947
|
}
|
|
3662
2948
|
|
|
3663
2949
|
export async function Inference_inferLambdaCall$(self_, environment_, expected_, term_, $task) {
|
|
3664
|
-
const e_ = (((_1) => {
|
|
3665
2950
|
{
|
|
2951
|
+
const _1 = term_;
|
|
3666
2952
|
if(_1.ECall) {
|
|
3667
2953
|
const e_ = _1;
|
|
3668
|
-
return e_
|
|
3669
|
-
return
|
|
3670
|
-
}
|
|
3671
|
-
}
|
|
3672
|
-
{
|
|
3673
|
-
return ff_compiler_Inference.fail_(term_.at_, "Call expected")
|
|
3674
|
-
return
|
|
3675
|
-
}
|
|
3676
|
-
}))(term_);
|
|
3677
2954
|
const call_ = (((_1) => {
|
|
3678
|
-
{
|
|
3679
2955
|
if(_1.DynamicCall) {
|
|
3680
2956
|
const call_ = _1;
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
2957
|
+
if((!call_.tailCall_)) {
|
|
2958
|
+
return {
|
|
2959
|
+
function_: call_.function_,
|
|
2960
|
+
tailCall_: call_.tailCall_
|
|
3685
2961
|
}
|
|
2962
|
+
return
|
|
3686
2963
|
}
|
|
3687
2964
|
}
|
|
3688
|
-
{
|
|
3689
2965
|
if(_1.DynamicCall) {
|
|
3690
2966
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(e_.at_, "Tailcalls not supported on lambda functions"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
3691
|
-
return
|
|
3692
|
-
}
|
|
3693
2967
|
}
|
|
3694
|
-
{
|
|
3695
2968
|
if(_1.StaticCall) {
|
|
3696
2969
|
return ff_compiler_Inference.fail_(e_.at_, "Internal error: Static calls not expected in inferLambdaCall")
|
|
3697
|
-
return
|
|
3698
|
-
}
|
|
3699
2970
|
}
|
|
3700
2971
|
}))(e_.target_);
|
|
3701
2972
|
const effect_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, term_.at_);
|
|
@@ -3716,7 +2987,6 @@ const _1 = argument_;
|
|
|
3716
2987
|
{
|
|
3717
2988
|
const _c = _1;
|
|
3718
2989
|
return ff_compiler_Syntax.Argument(_c.at_, _c.name_, ff_compiler_Inference.Inference_inferTerm(self_, environment_, t_, argument_.value_))
|
|
3719
|
-
return
|
|
3720
2990
|
}
|
|
3721
2991
|
}
|
|
3722
2992
|
return
|
|
@@ -3736,31 +3006,25 @@ return ff_compiler_Syntax.DynamicCall(function_, _c.tailCall_)
|
|
|
3736
3006
|
return
|
|
3737
3007
|
}
|
|
3738
3008
|
}
|
|
3009
|
+
return
|
|
3010
|
+
}
|
|
3011
|
+
{
|
|
3012
|
+
return ff_compiler_Inference.fail_(term_.at_, "Call expected")
|
|
3013
|
+
}
|
|
3014
|
+
}
|
|
3739
3015
|
}
|
|
3740
3016
|
|
|
3741
3017
|
export async function Inference_inferOperator$(self_, environment_, expected_, operator_, term_, $task) {
|
|
3742
|
-
const e_ = (((_1) => {
|
|
3743
3018
|
{
|
|
3019
|
+
const _1 = term_;
|
|
3744
3020
|
if(_1.ECall) {
|
|
3745
3021
|
const e_ = _1;
|
|
3746
|
-
return e_
|
|
3747
|
-
return
|
|
3748
|
-
}
|
|
3749
|
-
}
|
|
3750
|
-
{
|
|
3751
|
-
return ff_compiler_Inference.fail_(term_.at_, "Call expected")
|
|
3752
|
-
return
|
|
3753
|
-
}
|
|
3754
|
-
}))(term_);
|
|
3755
3022
|
const target_ = ff_compiler_Syntax.StaticCall(operator_, false, false);
|
|
3756
3023
|
{
|
|
3757
3024
|
const _1 = e_.arguments_;
|
|
3758
|
-
{
|
|
3759
|
-
if(_1.length > 0) {
|
|
3760
|
-
const a1_ = _1[0];
|
|
3761
3025
|
if(_1.length === 1) {
|
|
3762
|
-
const
|
|
3763
|
-
if(
|
|
3026
|
+
const a1_ = _1[0];
|
|
3027
|
+
if((operator_ === "!")) {
|
|
3764
3028
|
const t_ = ff_compiler_Syntax.TConstructor(e_.at_, ff_compiler_Inference.core_("Bool"), []);
|
|
3765
3029
|
const e1_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, t_, a1_.value_);
|
|
3766
3030
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t_);
|
|
@@ -3777,52 +3041,33 @@ return
|
|
|
3777
3041
|
return
|
|
3778
3042
|
}
|
|
3779
3043
|
}
|
|
3780
|
-
}
|
|
3781
|
-
}
|
|
3782
|
-
{
|
|
3783
|
-
if(_1.length > 0) {
|
|
3784
|
-
const a1_ = _1[0];
|
|
3785
3044
|
if(_1.length === 1) {
|
|
3786
|
-
const
|
|
3787
|
-
if(
|
|
3045
|
+
const a1_ = _1[0];
|
|
3046
|
+
if((operator_ === "-")) {
|
|
3788
3047
|
const t1_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, e_.at_);
|
|
3789
3048
|
const e1_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, t1_, a1_.value_);
|
|
3790
3049
|
do {
|
|
3791
3050
|
const _1 = ff_compiler_Unification.Unification_substitute(self_.unification_, t1_);
|
|
3792
|
-
{
|
|
3793
|
-
if(_1.TConstructor) {
|
|
3051
|
+
if(_1.TConstructor && _1.generics_.length === 0) {
|
|
3794
3052
|
const name_ = _1.name_;
|
|
3795
|
-
if(
|
|
3796
|
-
const _guard1 = (name_ === ff_compiler_Inference.core_("Float"));
|
|
3797
|
-
if(_guard1) {
|
|
3053
|
+
if((name_ === ff_compiler_Inference.core_("Float"))) {
|
|
3798
3054
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t1_)
|
|
3799
3055
|
break
|
|
3800
3056
|
}
|
|
3801
3057
|
}
|
|
3802
|
-
|
|
3803
|
-
}
|
|
3804
|
-
{
|
|
3805
|
-
if(_1.TConstructor) {
|
|
3058
|
+
if(_1.TConstructor && _1.generics_.length === 0) {
|
|
3806
3059
|
const name_ = _1.name_;
|
|
3807
|
-
if(
|
|
3808
|
-
const _guard1 = (name_ === ff_compiler_Inference.core_("Int"));
|
|
3809
|
-
if(_guard1) {
|
|
3060
|
+
if((name_ === ff_compiler_Inference.core_("Int"))) {
|
|
3810
3061
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t1_)
|
|
3811
3062
|
break
|
|
3812
3063
|
}
|
|
3813
3064
|
}
|
|
3814
|
-
|
|
3815
|
-
}
|
|
3816
|
-
{
|
|
3817
|
-
const _guard1 = ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_);
|
|
3818
|
-
if(_guard1) {
|
|
3065
|
+
if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
|
|
3819
3066
|
|
|
3820
3067
|
break
|
|
3821
3068
|
}
|
|
3822
|
-
}
|
|
3823
3069
|
{
|
|
3824
3070
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(e_.at_, "Operators on unknown types not currently supported"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
3825
|
-
break
|
|
3826
3071
|
}
|
|
3827
3072
|
} while(false);
|
|
3828
3073
|
{
|
|
@@ -3838,16 +3083,10 @@ return
|
|
|
3838
3083
|
return
|
|
3839
3084
|
}
|
|
3840
3085
|
}
|
|
3841
|
-
|
|
3842
|
-
}
|
|
3843
|
-
{
|
|
3844
|
-
if(_1.length > 0) {
|
|
3086
|
+
if(_1.length === 2) {
|
|
3845
3087
|
const a1_ = _1[0];
|
|
3846
|
-
if(_1.length > 1) {
|
|
3847
3088
|
const a2_ = _1[1];
|
|
3848
|
-
if(
|
|
3849
|
-
const _guard1 = ((operator_ === "||") || (operator_ === "&&"));
|
|
3850
|
-
if(_guard1) {
|
|
3089
|
+
if(((operator_ === "||") || (operator_ === "&&"))) {
|
|
3851
3090
|
const t_ = ff_compiler_Syntax.TConstructor(e_.at_, ff_compiler_Inference.core_("Bool"), []);
|
|
3852
3091
|
const e1_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, t_, a1_.value_);
|
|
3853
3092
|
const e2_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, t_, a2_.value_);
|
|
@@ -3867,17 +3106,10 @@ return
|
|
|
3867
3106
|
return
|
|
3868
3107
|
}
|
|
3869
3108
|
}
|
|
3870
|
-
|
|
3871
|
-
}
|
|
3872
|
-
}
|
|
3873
|
-
{
|
|
3874
|
-
if(_1.length > 0) {
|
|
3109
|
+
if(_1.length === 2) {
|
|
3875
3110
|
const a1_ = _1[0];
|
|
3876
|
-
if(_1.length > 1) {
|
|
3877
3111
|
const a2_ = _1[1];
|
|
3878
|
-
if(
|
|
3879
|
-
const _guard1 = ((operator_ === "===") || (operator_ === "!=="));
|
|
3880
|
-
if(_guard1) {
|
|
3112
|
+
if(((operator_ === "===") || (operator_ === "!=="))) {
|
|
3881
3113
|
const t1_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, e_.at_);
|
|
3882
3114
|
const e1_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, t1_, a1_.value_);
|
|
3883
3115
|
const e2_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, t1_, a2_.value_);
|
|
@@ -3897,17 +3129,10 @@ return
|
|
|
3897
3129
|
return
|
|
3898
3130
|
}
|
|
3899
3131
|
}
|
|
3900
|
-
|
|
3901
|
-
}
|
|
3902
|
-
}
|
|
3903
|
-
{
|
|
3904
|
-
if(_1.length > 0) {
|
|
3132
|
+
if(_1.length === 2) {
|
|
3905
3133
|
const a1_ = _1[0];
|
|
3906
|
-
if(_1.length > 1) {
|
|
3907
3134
|
const a2_ = _1[1];
|
|
3908
|
-
if(
|
|
3909
|
-
const _guard1 = ((((((operator_ === "+") || (operator_ === "-")) || (operator_ === "*")) || (operator_ === "/")) || (operator_ === "%")) || (operator_ === "^"));
|
|
3910
|
-
if(_guard1) {
|
|
3135
|
+
if(((((((operator_ === "+") || (operator_ === "-")) || (operator_ === "*")) || (operator_ === "/")) || (operator_ === "%")) || (operator_ === "^"))) {
|
|
3911
3136
|
const t1_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, e_.at_);
|
|
3912
3137
|
const t2_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, e_.at_);
|
|
3913
3138
|
const e1_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, t1_, a1_.value_);
|
|
@@ -3915,149 +3140,73 @@ const e2_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, t2_,
|
|
|
3915
3140
|
const magic_ = ((t_) => {
|
|
3916
3141
|
{
|
|
3917
3142
|
const _1 = ff_compiler_Unification.Unification_substitute(self_.unification_, t_);
|
|
3918
|
-
{
|
|
3919
|
-
if(_1.TConstructor) {
|
|
3143
|
+
if(_1.TConstructor && _1.generics_.length === 0) {
|
|
3920
3144
|
const name_ = _1.name_;
|
|
3921
|
-
if(
|
|
3922
|
-
const _guard1 = (name_ === ff_compiler_Inference.core_("Float"));
|
|
3923
|
-
if(_guard1) {
|
|
3145
|
+
if((name_ === ff_compiler_Inference.core_("Float"))) {
|
|
3924
3146
|
return ff_core_Option.Some("Float")
|
|
3925
|
-
return
|
|
3926
|
-
}
|
|
3927
3147
|
}
|
|
3928
3148
|
}
|
|
3929
|
-
|
|
3930
|
-
{
|
|
3931
|
-
if(_1.TConstructor) {
|
|
3149
|
+
if(_1.TConstructor && _1.generics_.length === 0) {
|
|
3932
3150
|
const name_ = _1.name_;
|
|
3933
|
-
if(
|
|
3934
|
-
const _guard1 = (name_ === ff_compiler_Inference.core_("Int"));
|
|
3935
|
-
if(_guard1) {
|
|
3151
|
+
if((name_ === ff_compiler_Inference.core_("Int"))) {
|
|
3936
3152
|
return ff_core_Option.Some("Int")
|
|
3937
|
-
return
|
|
3938
|
-
}
|
|
3939
3153
|
}
|
|
3940
3154
|
}
|
|
3941
|
-
|
|
3942
|
-
{
|
|
3943
|
-
if(_1.TConstructor) {
|
|
3155
|
+
if(_1.TConstructor && _1.generics_.length === 0) {
|
|
3944
3156
|
const name_ = _1.name_;
|
|
3945
|
-
if(
|
|
3946
|
-
const _guard1 = ((operator_ === "+") && (name_ === ff_compiler_Inference.core_("String")));
|
|
3947
|
-
if(_guard1) {
|
|
3157
|
+
if(((operator_ === "+") && (name_ === ff_compiler_Inference.core_("String")))) {
|
|
3948
3158
|
return ff_core_Option.Some("String")
|
|
3949
|
-
return
|
|
3950
|
-
}
|
|
3951
|
-
}
|
|
3952
3159
|
}
|
|
3953
3160
|
}
|
|
3954
3161
|
{
|
|
3955
3162
|
return ff_core_Option.None()
|
|
3956
|
-
return
|
|
3957
3163
|
}
|
|
3958
3164
|
}
|
|
3959
3165
|
});
|
|
3960
3166
|
const chooseType_ = ((_1, _2) => {
|
|
3961
|
-
{
|
|
3962
|
-
if(_1.Some) {
|
|
3963
|
-
if(_1.value_ === "String") {
|
|
3964
|
-
if(_2.Some) {
|
|
3167
|
+
if(_1.Some && _1.value_ === "String" && _2.Some) {
|
|
3965
3168
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t1_)
|
|
3966
3169
|
return
|
|
3967
3170
|
}
|
|
3968
|
-
|
|
3969
|
-
}
|
|
3970
|
-
}
|
|
3971
|
-
{
|
|
3972
|
-
if(_1.Some) {
|
|
3973
|
-
if(_2.Some) {
|
|
3974
|
-
if(_2.value_ === "String") {
|
|
3171
|
+
if(_1.Some && _2.Some && _2.value_ === "String") {
|
|
3975
3172
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t2_)
|
|
3976
3173
|
return
|
|
3977
3174
|
}
|
|
3978
|
-
|
|
3979
|
-
}
|
|
3980
|
-
}
|
|
3981
|
-
{
|
|
3982
|
-
if(_1.Some) {
|
|
3983
|
-
if(_1.value_ === "Float") {
|
|
3984
|
-
if(_2.Some) {
|
|
3175
|
+
if(_1.Some && _1.value_ === "Float" && _2.Some) {
|
|
3985
3176
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t1_)
|
|
3986
3177
|
return
|
|
3987
3178
|
}
|
|
3988
|
-
|
|
3989
|
-
}
|
|
3990
|
-
}
|
|
3991
|
-
{
|
|
3992
|
-
if(_1.Some) {
|
|
3993
|
-
if(_2.Some) {
|
|
3994
|
-
if(_2.value_ === "Float") {
|
|
3179
|
+
if(_1.Some && _2.Some && _2.value_ === "Float") {
|
|
3995
3180
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t2_)
|
|
3996
3181
|
return
|
|
3997
3182
|
}
|
|
3998
|
-
|
|
3999
|
-
}
|
|
4000
|
-
}
|
|
4001
|
-
{
|
|
4002
|
-
if(_1.Some) {
|
|
4003
|
-
if(_1.value_ === "Int") {
|
|
4004
|
-
if(_2.Some) {
|
|
3183
|
+
if(_1.Some && _1.value_ === "Int" && _2.Some) {
|
|
4005
3184
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t1_)
|
|
4006
3185
|
return
|
|
4007
3186
|
}
|
|
4008
|
-
|
|
4009
|
-
}
|
|
4010
|
-
}
|
|
4011
|
-
{
|
|
4012
|
-
if(_1.Some) {
|
|
4013
|
-
if(_2.Some) {
|
|
4014
|
-
if(_2.value_ === "Int") {
|
|
3187
|
+
if(_1.Some && _2.Some && _2.value_ === "Int") {
|
|
4015
3188
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t2_)
|
|
4016
3189
|
return
|
|
4017
3190
|
}
|
|
4018
|
-
|
|
4019
|
-
}
|
|
4020
|
-
}
|
|
4021
|
-
{
|
|
4022
|
-
if(_1.Some) {
|
|
4023
|
-
if(_2.None) {
|
|
3191
|
+
if(_1.Some && _2.None) {
|
|
4024
3192
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, t1_, t2_);
|
|
4025
3193
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t1_)
|
|
4026
3194
|
return
|
|
4027
3195
|
}
|
|
4028
|
-
|
|
4029
|
-
}
|
|
4030
|
-
{
|
|
4031
|
-
if(_1.None) {
|
|
4032
|
-
if(_2.Some) {
|
|
3196
|
+
if(_1.None && _2.Some) {
|
|
4033
3197
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, t2_, t1_);
|
|
4034
3198
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t2_)
|
|
4035
3199
|
return
|
|
4036
3200
|
}
|
|
4037
|
-
|
|
4038
|
-
}
|
|
4039
|
-
{
|
|
4040
|
-
const _guard1 = ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_);
|
|
4041
|
-
if(_guard1) {
|
|
3201
|
+
if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
|
|
4042
3202
|
|
|
4043
3203
|
return
|
|
4044
3204
|
}
|
|
4045
|
-
|
|
4046
|
-
{
|
|
4047
|
-
if(_1.Some) {
|
|
4048
|
-
if(_2.Some) {
|
|
3205
|
+
if(_1.Some && _2.Some) {
|
|
4049
3206
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(e_.at_, "Operators on these types not currently supported"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
4050
|
-
return
|
|
4051
|
-
}
|
|
4052
|
-
}
|
|
4053
3207
|
}
|
|
4054
|
-
{
|
|
4055
|
-
if(_1.None) {
|
|
4056
|
-
if(_2.None) {
|
|
3208
|
+
if(_1.None && _2.None) {
|
|
4057
3209
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(e_.at_, "Operators on unknown types not currently supported"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
4058
|
-
return
|
|
4059
|
-
}
|
|
4060
|
-
}
|
|
4061
3210
|
}
|
|
4062
3211
|
});
|
|
4063
3212
|
chooseType_(magic_(t1_), magic_(t2_));
|
|
@@ -4076,19 +3225,17 @@ return
|
|
|
4076
3225
|
return
|
|
4077
3226
|
}
|
|
4078
3227
|
}
|
|
3228
|
+
if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
|
|
3229
|
+
return term_
|
|
4079
3230
|
}
|
|
3231
|
+
{
|
|
3232
|
+
return ff_compiler_Inference.fail_(e_.at_, ("Unknown operator: " + operator_))
|
|
4080
3233
|
}
|
|
4081
3234
|
}
|
|
4082
|
-
{
|
|
4083
|
-
const _guard1 = ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_);
|
|
4084
|
-
if(_guard1) {
|
|
4085
|
-
return term_
|
|
4086
3235
|
return
|
|
4087
3236
|
}
|
|
4088
|
-
}
|
|
4089
3237
|
{
|
|
4090
|
-
return ff_compiler_Inference.fail_(
|
|
4091
|
-
return
|
|
3238
|
+
return ff_compiler_Inference.fail_(term_.at_, "Call expected")
|
|
4092
3239
|
}
|
|
4093
3240
|
}
|
|
4094
3241
|
}
|
|
@@ -4168,7 +3315,6 @@ ff_core_Array.Array_delete(remainingArguments_, _w1, 1)
|
|
|
4168
3315
|
}));
|
|
4169
3316
|
const e2_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, t_, e_);
|
|
4170
3317
|
return ff_compiler_Syntax.Argument(at_, ff_core_Option.Some(p_.name_), e2_)
|
|
4171
|
-
return
|
|
4172
3318
|
}
|
|
4173
3319
|
})), (() => {
|
|
4174
3320
|
return defaultArgument_()
|
|
@@ -4177,21 +3323,17 @@ return defaultArgument_()
|
|
|
4177
3323
|
}));
|
|
4178
3324
|
if((!ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_))) {
|
|
4179
3325
|
ff_core_Option.Option_each(ff_core_Array.Array_first(remainingArguments_), ((_1) => {
|
|
4180
|
-
{
|
|
4181
|
-
const callAt_ = _1.at_;
|
|
4182
3326
|
if(_1.name_.None) {
|
|
3327
|
+
const callAt_ = _1.at_;
|
|
4183
3328
|
ff_compiler_Inference.fail_(callAt_, "Too many arguments")
|
|
4184
3329
|
return
|
|
4185
3330
|
}
|
|
4186
|
-
}
|
|
4187
|
-
{
|
|
4188
|
-
const callAt_ = _1.at_;
|
|
4189
3331
|
if(_1.name_.Some) {
|
|
3332
|
+
const callAt_ = _1.at_;
|
|
4190
3333
|
const n_ = _1.name_.value_;
|
|
4191
3334
|
ff_compiler_Inference.fail_(callAt_, ("Unknown argument: " + n_))
|
|
4192
3335
|
return
|
|
4193
3336
|
}
|
|
4194
|
-
}
|
|
4195
3337
|
}));
|
|
4196
3338
|
return newArguments_
|
|
4197
3339
|
} else {
|
|
@@ -4201,7 +3343,6 @@ const _1 = a_;
|
|
|
4201
3343
|
{
|
|
4202
3344
|
const _c = _1;
|
|
4203
3345
|
return ff_compiler_Syntax.Argument(_c.at_, _c.name_, ff_compiler_Inference.Inference_inferTerm(self_, environment_, ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, a_.at_), a_.value_))
|
|
4204
|
-
return
|
|
4205
3346
|
}
|
|
4206
3347
|
}
|
|
4207
3348
|
}))]
|
|
@@ -4264,7 +3405,6 @@ const _1 = p_;
|
|
|
4264
3405
|
{
|
|
4265
3406
|
const _c = _1;
|
|
4266
3407
|
return ff_compiler_Syntax.Parameter(_c.at_, _c.mutable_, _c.name_, ff_compiler_Unification.Unification_instantiate(self_.unification_, instantiationMap_, p_.valueType_), _c.default_)
|
|
4267
|
-
return
|
|
4268
3408
|
}
|
|
4269
3409
|
}
|
|
4270
3410
|
}));
|
|
@@ -4285,14 +3425,12 @@ return ff_compiler_Environment.Scheme(_c.isVariable_, _c.isMutable_, _c.isNewtyp
|
|
|
4285
3425
|
if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, scheme_.signature_.at_))) {
|
|
4286
3426
|
const symbolHook_ = ff_compiler_LspHook.SymbolHook(symbol_, at_, scheme_.signature_.at_);
|
|
4287
3427
|
const emittedHook_ = (((_1) => {
|
|
4288
|
-
{
|
|
4289
3428
|
if(_1.InferLookupHook) {
|
|
4290
3429
|
const h_ = _1;
|
|
4291
3430
|
h_.symbol_.value_ = symbolHook_;
|
|
4292
3431
|
h_.instantiated_.value_ = ff_core_Option.Some(instantiated_)
|
|
4293
3432
|
return
|
|
4294
3433
|
}
|
|
4295
|
-
}
|
|
4296
3434
|
{
|
|
4297
3435
|
|
|
4298
3436
|
return
|