firefly-compiler 0.5.35 → 0.5.37
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/.hintrc +4 -4
- package/.vscode/settings.json +4 -4
- package/bin/Release.ff +157 -154
- package/bin/firefly.mjs +1 -1
- package/compiler/Builder.ff +275 -277
- package/compiler/Compiler.ff +234 -233
- package/compiler/Dependencies.ff +186 -187
- package/compiler/DependencyLock.ff +17 -17
- package/compiler/Deriver.ff +23 -31
- package/compiler/Dictionaries.ff +1 -1
- package/compiler/Inference.ff +43 -20
- package/compiler/JsEmitter.ff +1437 -1282
- package/compiler/LspHook.ff +202 -202
- package/compiler/Main.ff +25 -24
- package/compiler/ModuleCache.ff +178 -178
- package/compiler/Parser.ff +36 -109
- package/compiler/Resolver.ff +5 -8
- package/compiler/Substitution.ff +1 -1
- package/compiler/Syntax.ff +1 -16
- package/compiler/Token.ff +9 -0
- package/compiler/Tokenizer.ff +4 -0
- package/compiler/Workspace.ff +88 -88
- package/core/.firefly/include/package.json +5 -5
- package/core/.firefly/package.ff +2 -2
- package/core/Any.ff +26 -30
- package/core/Array.ff +298 -265
- package/core/Atomic.ff +63 -64
- package/core/Box.ff +7 -7
- package/core/BrowserSystem.ff +40 -40
- package/core/Buffer.ff +185 -152
- package/core/BuildSystem.ff +156 -148
- package/core/Channel.ff +95 -92
- package/core/Char.ff +3 -2
- package/core/Core.ff +16 -23
- package/core/Crypto.ff +94 -96
- package/core/Equal.ff +41 -36
- package/core/Error.ff +15 -10
- package/core/FileHandle.ff +45 -37
- package/core/Float.ff +176 -200
- package/core/HttpClient.ff +142 -148
- package/core/Instant.ff +6 -8
- package/core/Int.ff +40 -24
- package/core/IntMap.ff +61 -39
- package/core/Js.ff +305 -0
- package/core/JsSystem.ff +135 -114
- package/core/JsValue.ff +303 -159
- package/core/Json.ff +423 -443
- package/core/List.ff +482 -486
- package/core/Lock.ff +108 -144
- package/core/Log.ff +25 -14
- package/core/NodeSystem.ff +198 -191
- package/core/Ordering.ff +160 -161
- package/core/Path.ff +377 -409
- package/core/Queue.ff +90 -0
- package/core/Random.ff +140 -134
- package/core/RbMap.ff +216 -216
- package/core/Serializable.ff +16 -13
- package/core/Show.ff +44 -43
- package/core/SourceLocation.ff +68 -68
- package/core/Stream.ff +1 -1
- package/core/String.ff +224 -202
- package/core/StringMap.ff +58 -36
- package/core/Task.ff +165 -149
- package/experimental/benchmarks/ListGrab.ff +23 -23
- package/experimental/benchmarks/ListGrab.java +55 -55
- package/experimental/benchmarks/Pyrotek45.ff +30 -30
- package/experimental/benchmarks/Pyrotek45.java +64 -64
- package/experimental/bidirectional/Bidi.ff +88 -88
- package/experimental/lines/Main.ff +40 -0
- package/experimental/random/Index.ff +53 -53
- package/experimental/random/Process.ff +120 -120
- package/experimental/random/RunLength.ff +65 -65
- package/experimental/random/Scrape.ff +51 -51
- package/experimental/random/Symbols.ff +73 -73
- package/experimental/random/Tensor.ff +52 -52
- package/experimental/random/Units.ff +36 -36
- package/experimental/s3/S3TestAuthorizationHeader.ff +39 -39
- package/experimental/s3/S3TestPut.ff +16 -16
- package/experimental/tests/TestJson.ff +26 -26
- package/firefly.sh +0 -0
- package/fireflysite/.firefly/package.ff +4 -4
- package/fireflysite/CommunityOverview.ff +20 -20
- package/fireflysite/CountingButtonDemo.ff +58 -58
- package/fireflysite/DocumentParser.ff +325 -331
- package/fireflysite/ExamplesOverview.ff +40 -40
- package/fireflysite/FrontPage.ff +344 -344
- package/fireflysite/GettingStarted.ff +45 -45
- package/fireflysite/Guide.ff +456 -456
- package/fireflysite/Main.ff +163 -152
- package/fireflysite/MatchingPasswordsDemo.ff +82 -82
- package/fireflysite/PackagesOverview.ff +49 -49
- package/fireflysite/PostgresqlDemo.ff +34 -34
- package/fireflysite/ReferenceAll.ff +18 -18
- package/fireflysite/ReferenceIntroduction.ff +11 -11
- package/fireflysite/Styles.ff +567 -567
- package/fireflysite/Test.ff +121 -62
- package/fireflysite/assets/markdown/reference/BaseTypes.md +209 -209
- package/fireflysite/assets/markdown/reference/EmittedJavascript.md +65 -65
- package/fireflysite/assets/markdown/reference/Exceptions.md +101 -101
- package/fireflysite/assets/markdown/reference/FunctionsAndMethods.md +364 -364
- package/fireflysite/assets/markdown/reference/JavascriptInterop.md +235 -172
- package/fireflysite/assets/markdown/reference/ModulesAndPackages.md +162 -162
- package/fireflysite/assets/markdown/reference/OldStructuredConcurrency.md +48 -48
- package/fireflysite/assets/markdown/reference/PatternMatching.md +224 -224
- package/fireflysite/assets/markdown/reference/StatementsAndExpressions.md +86 -86
- package/fireflysite/assets/markdown/reference/StructuredConcurrency.md +99 -99
- package/fireflysite/assets/markdown/reference/TraitsAndInstances.md +100 -100
- package/fireflysite/assets/markdown/reference/UserDefinedTypes.md +184 -184
- package/fireflysite/assets/markdown/scratch/ControlFlow.md +136 -136
- package/fireflysite/assets/markdown/scratch/Toc.md +40 -40
- package/lsp/.firefly/package.ff +1 -1
- package/lsp/CompletionHandler.ff +827 -827
- package/lsp/Handler.ff +714 -714
- package/lsp/HoverHandler.ff +79 -79
- package/lsp/LanguageServer.ff +272 -272
- package/lsp/SignatureHelpHandler.ff +55 -55
- package/lsp/SymbolHandler.ff +181 -181
- package/lsp/TestReferences.ff +17 -17
- package/lsp/TestReferencesCase.ff +7 -7
- package/lsp/stderr.txt +1 -1
- package/lsp/stdout.txt +34 -34
- package/lux/.firefly/package.ff +1 -1
- package/lux/Css.ff +648 -648
- package/lux/CssTest.ff +48 -48
- package/lux/Lux.ff +608 -617
- package/lux/LuxEvent.ff +79 -116
- package/lux/Main.ff +123 -123
- package/lux/Main2.ff +143 -143
- package/lux/TestDry.ff +28 -28
- package/output/js/ff/compiler/Builder.mjs +72 -71
- package/output/js/ff/compiler/Compiler.mjs +19 -13
- package/output/js/ff/compiler/Dependencies.mjs +8 -7
- package/output/js/ff/compiler/DependencyLock.mjs +6 -4
- package/output/js/ff/compiler/Deriver.mjs +26 -24
- package/output/js/ff/compiler/Dictionaries.mjs +14 -18
- package/output/js/ff/compiler/Environment.mjs +6 -4
- package/output/js/ff/compiler/Inference.mjs +238 -164
- package/output/js/ff/compiler/JsEmitter.mjs +1160 -350
- package/output/js/ff/compiler/JsImporter.mjs +20 -18
- package/output/js/ff/compiler/LspHook.mjs +12 -10
- package/output/js/ff/compiler/Main.mjs +61 -41
- package/output/js/ff/compiler/ModuleCache.mjs +10 -8
- package/output/js/ff/compiler/Parser.mjs +153 -669
- package/output/js/ff/compiler/Patterns.mjs +12 -10
- package/output/js/ff/compiler/Resolver.mjs +52 -78
- package/output/js/ff/compiler/Substitution.mjs +12 -16
- package/output/js/ff/compiler/Syntax.mjs +50 -341
- package/output/js/ff/compiler/Token.mjs +126 -4
- package/output/js/ff/compiler/Tokenizer.mjs +62 -52
- package/output/js/ff/compiler/Unification.mjs +74 -90
- package/output/js/ff/compiler/Wildcards.mjs +4 -2
- package/output/js/ff/compiler/Workspace.mjs +26 -20
- package/output/js/ff/core/Any.mjs +20 -20
- package/output/js/ff/core/Array.mjs +268 -175
- package/output/js/ff/core/AssetSystem.mjs +8 -6
- package/output/js/ff/core/Atomic.mjs +84 -52
- package/output/js/ff/core/Bool.mjs +6 -4
- package/output/js/ff/core/BrowserSystem.mjs +38 -29
- package/output/js/ff/core/Buffer.mjs +285 -133
- package/output/js/ff/core/BuildSystem.mjs +36 -56
- package/output/js/ff/core/Channel.mjs +250 -97
- package/output/js/ff/core/Char.mjs +5 -3
- package/output/js/ff/core/Core.mjs +28 -34
- package/output/js/ff/core/Crypto.mjs +30 -52
- package/output/js/ff/core/Duration.mjs +4 -2
- package/output/js/ff/core/Equal.mjs +14 -12
- package/output/js/ff/core/Error.mjs +17 -11
- package/output/js/ff/core/FileHandle.mjs +76 -38
- package/output/js/ff/core/Float.mjs +92 -160
- package/output/js/ff/core/HttpClient.mjs +208 -76
- package/output/js/ff/core/Instant.mjs +8 -10
- package/output/js/ff/core/Int.mjs +36 -26
- package/output/js/ff/core/IntMap.mjs +79 -33
- package/output/js/ff/core/Js.mjs +751 -0
- package/output/js/ff/core/JsSystem.mjs +54 -60
- package/output/js/ff/core/JsValue.mjs +294 -143
- package/output/js/ff/core/Json.mjs +443 -253
- package/output/js/ff/core/List.mjs +262 -214
- package/output/js/ff/core/Lock.mjs +156 -125
- package/output/js/ff/core/Log.mjs +20 -10
- package/output/js/ff/core/Map.mjs +10 -8
- package/output/js/ff/core/NodeSystem.mjs +189 -123
- package/output/js/ff/core/Nothing.mjs +4 -2
- package/output/js/ff/core/Option.mjs +40 -38
- package/output/js/ff/core/Ordering.mjs +26 -20
- package/output/js/ff/core/Pair.mjs +4 -2
- package/output/js/ff/core/Path.mjs +517 -315
- package/output/js/ff/core/Queue.mjs +306 -0
- package/output/js/ff/core/Random.mjs +141 -77
- package/output/js/ff/core/RbMap.mjs +36 -34
- package/output/js/ff/core/Serializable.mjs +44 -28
- package/output/js/ff/core/Set.mjs +6 -4
- package/output/js/ff/core/Show.mjs +8 -6
- package/output/js/ff/core/SourceLocation.mjs +4 -2
- package/output/js/ff/core/Stream.mjs +30 -50
- package/output/js/ff/core/String.mjs +263 -172
- package/output/js/ff/core/StringMap.mjs +77 -31
- package/output/js/ff/core/Task.mjs +91 -76
- package/output/js/ff/core/Try.mjs +20 -18
- package/output/js/ff/core/Unit.mjs +4 -2
- package/package.json +1 -1
- package/postgresql/Pg.ff +53 -59
- package/rpc/.firefly/package.ff +1 -1
- package/rpc/Rpc.ff +70 -70
- package/s3/.firefly/package.ff +1 -1
- package/s3/S3.ff +92 -94
- package/vscode/LICENSE.txt +21 -21
- package/vscode/Prepublish.ff +15 -15
- package/vscode/README.md +16 -16
- package/vscode/client/package-lock.json +544 -544
- package/vscode/client/package.json +22 -22
- package/vscode/client/src/extension.ts +104 -104
- package/vscode/icons/firefly-icon.svg +10 -10
- package/vscode/language-configuration.json +61 -61
- package/vscode/package-lock.json +3623 -3623
- package/vscode/package.json +1 -1
- package/vscode/snippets.json +241 -241
- package/vscode/syntaxes/firefly-markdown-injection.json +45 -45
- package/webserver/.firefly/include/package.json +5 -5
- package/webserver/.firefly/package.ff +2 -2
- package/webserver/WebServer.ff +647 -685
- package/websocket/.firefly/package.ff +1 -1
- package/websocket/WebSocket.ff +100 -131
- package/core/UnsafeJs.ff +0 -42
- package/output/js/ff/core/UnsafeJs.mjs +0 -191
|
@@ -54,6 +54,8 @@ import * as ff_core_Int from "../../ff/core/Int.mjs"
|
|
|
54
54
|
|
|
55
55
|
import * as ff_core_IntMap from "../../ff/core/IntMap.mjs"
|
|
56
56
|
|
|
57
|
+
import * as ff_core_Js from "../../ff/core/Js.mjs"
|
|
58
|
+
|
|
57
59
|
import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
|
|
58
60
|
|
|
59
61
|
import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
|
|
@@ -80,6 +82,8 @@ import * as ff_core_Pair from "../../ff/core/Pair.mjs"
|
|
|
80
82
|
|
|
81
83
|
import * as ff_core_Path from "../../ff/core/Path.mjs"
|
|
82
84
|
|
|
85
|
+
import * as ff_core_Queue from "../../ff/core/Queue.mjs"
|
|
86
|
+
|
|
83
87
|
import * as ff_core_Random from "../../ff/core/Random.mjs"
|
|
84
88
|
|
|
85
89
|
import * as ff_core_Serializable from "../../ff/core/Serializable.mjs"
|
|
@@ -102,8 +106,6 @@ import * as ff_core_Try from "../../ff/core/Try.mjs"
|
|
|
102
106
|
|
|
103
107
|
import * as ff_core_Unit from "../../ff/core/Unit.mjs"
|
|
104
108
|
|
|
105
|
-
import * as ff_core_UnsafeJs from "../../ff/core/UnsafeJs.mjs"
|
|
106
|
-
|
|
107
109
|
// type Inference
|
|
108
110
|
export function Inference(unification_, missing_, lspHook_) {
|
|
109
111
|
return {unification_, missing_, lspHook_};
|
|
@@ -130,7 +132,7 @@ if(_1.TConstructor) {
|
|
|
130
132
|
const name_ = _1.name_;
|
|
131
133
|
return name_
|
|
132
134
|
}
|
|
133
|
-
|
|
135
|
+
{
|
|
134
136
|
const at_ = _1.at_;
|
|
135
137
|
const i_ = _1.index_;
|
|
136
138
|
return ff_compiler_Inference.fail_(c_.at_, ("Unexpected unification variable: $" + i_))
|
|
@@ -159,7 +161,7 @@ if(_1.TConstructor) {
|
|
|
159
161
|
const name_ = _1.name_;
|
|
160
162
|
return name_
|
|
161
163
|
}
|
|
162
|
-
|
|
164
|
+
{
|
|
163
165
|
const at_ = _1.at_;
|
|
164
166
|
const i_ = _1.index_;
|
|
165
167
|
return ff_compiler_Inference.fail_(c_.at_, ("Unexpected unification variable: $" + i_))
|
|
@@ -217,7 +219,7 @@ if((traitDefinition_.generics_.length !== definition_.typeArguments_.length)) {
|
|
|
217
219
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(definition_.at_, ((((("Wrong number of type arguments for " + traitName_) + ", expected ") + (traitDefinition_.generics_.length - 1)) + ", got ") + (definition_.typeArguments_.length - 1))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
218
220
|
};
|
|
219
221
|
const instantiationMap_ = ff_core_List.List_toMap(ff_core_List.List_zip(traitDefinition_.generics_, definition_.typeArguments_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
220
|
-
for(let
|
|
222
|
+
for(let for_a = traitDefinition_.methods_, for_i = 0, for_l = for_a.length; for_i < for_l; for_i++) {
|
|
221
223
|
const traitMethod_ = for_a[for_i];
|
|
222
224
|
const found_ = ff_core_List.List_filter(definition_.methods_, ((_w1) => {
|
|
223
225
|
return (_w1.signature_.name_ === traitMethod_.name_)
|
|
@@ -225,7 +227,7 @@ return (_w1.signature_.name_ === traitMethod_.name_)
|
|
|
225
227
|
if(ff_core_List.List_isEmpty(found_)) {
|
|
226
228
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(definition_.at_, ("Missing instance method: " + traitMethod_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
227
229
|
};
|
|
228
|
-
for(let
|
|
230
|
+
for(let for_a = found_, for_i = 1, for_l = for_a.length; for_i < for_l; for_i++) {
|
|
229
231
|
const duplicateMethod_ = for_a[for_i];
|
|
230
232
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(duplicateMethod_.at_, ("Duplicated instance method: " + traitMethod_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
231
233
|
}
|
|
@@ -252,22 +254,19 @@ return ff_compiler_Syntax.Parameter(_c.at_, _c.mutable_, _c.name_, ff_compiler_U
|
|
|
252
254
|
}
|
|
253
255
|
}));
|
|
254
256
|
const returnType_ = ff_compiler_Unification.Unification_instantiate(self_.unification_, instantiationMap_, traitMethodScheme_.signature_.returnType_);
|
|
255
|
-
for(let for_i = Math.max(parameters_.length, 0),
|
|
257
|
+
for(let for_a = instanceFunction_.signature_.parameters_, for_i = Math.max(parameters_.length, 0), for_l = for_a.length; for_i < for_l; for_i++) {
|
|
256
258
|
const instanceParameter_ = for_a[for_i];
|
|
257
259
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(instanceParameter_.at_, ("Unexpected parameter: " + instanceParameter_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
258
260
|
};
|
|
259
|
-
for(let for_i = Math.max(instanceFunction_.signature_.parameters_.length, 0),
|
|
261
|
+
for(let for_a = parameters_, for_i = Math.max(instanceFunction_.signature_.parameters_.length, 0), for_l = for_a.length; for_i < for_l; for_i++) {
|
|
260
262
|
const traitParameter_ = for_a[for_i];
|
|
261
263
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(instanceFunction_.at_, ("Missing parameter: " + traitParameter_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
262
264
|
};
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
const
|
|
266
|
-
const instanceParameter_ = _1.second_;
|
|
265
|
+
for(let for_a = parameters_, for_i = 0, for_l = for_a.length, for_a2 = instanceFunction_.signature_.parameters_, for_i2 = 0, for_l2 = for_a2.length; for_i < for_l && for_i2 < for_l2; for_i++, for_i2++) {
|
|
266
|
+
const traitParameter_ = for_a[for_i];
|
|
267
|
+
const instanceParameter_ = for_a2[for_i2];
|
|
267
268
|
ff_compiler_Unification.Unification_unify(self_.unification_, instanceParameter_.valueType_.at_, traitParameter_.valueType_, instanceParameter_.valueType_)
|
|
268
|
-
|
|
269
|
-
}
|
|
270
|
-
}));
|
|
269
|
+
};
|
|
271
270
|
ff_compiler_Unification.Unification_unify(self_.unification_, instanceFunction_.signature_.returnType_.at_, returnType_, instanceFunction_.signature_.returnType_);
|
|
272
271
|
if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, instanceFunction_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, traitMethodScheme_.signature_.at_))) {
|
|
273
272
|
const symbolHook_ = ff_compiler_LspHook.SymbolHook(instanceFunction_.signature_.name_, instanceFunction_.at_, traitMethodScheme_.signature_.at_);
|
|
@@ -300,12 +299,8 @@ const functions_ = ff_core_List.List_map(definition_.methods_, ((method_) => {
|
|
|
300
299
|
const signature_ = (((_c) => {
|
|
301
300
|
return ff_compiler_Syntax.Signature(_c.at_, _c.name_, _c.member_, [...definition_.generics_, ...method_.signature_.generics_], [...definition_.constraints_, ...method_.signature_.constraints_], [selfParameter_, ...method_.signature_.parameters_], _c.returnType_, _c.effect_)
|
|
302
301
|
}))(method_.signature_);
|
|
303
|
-
const body_ =
|
|
304
|
-
{
|
|
305
|
-
const _1 = lambda_;
|
|
306
|
-
{
|
|
307
|
-
const _c = _1;
|
|
308
|
-
return ff_compiler_Syntax.Lambda(_c.at_, _c.effect_, ff_core_List.List_map(lambda_.cases_, ((case_) => {
|
|
302
|
+
const body_ = (((_c) => {
|
|
303
|
+
return ff_compiler_Syntax.Lambda(_c.at_, _c.effect_, ff_core_List.List_map(method_.body_.cases_, ((case_) => {
|
|
309
304
|
{
|
|
310
305
|
const _1 = case_;
|
|
311
306
|
{
|
|
@@ -314,10 +309,7 @@ return ff_compiler_Syntax.MatchCase(_c.at_, [ff_compiler_Syntax.PVariable(method
|
|
|
314
309
|
}
|
|
315
310
|
}
|
|
316
311
|
})))
|
|
317
|
-
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
}));
|
|
312
|
+
}))(method_.body_);
|
|
321
313
|
const function_ = (((_c) => {
|
|
322
314
|
return ff_compiler_Syntax.DFunction(_c.at_, signature_, body_)
|
|
323
315
|
}))(method_);
|
|
@@ -360,10 +352,7 @@ return ff_compiler_Unification.Unification_withLocalInstances(self_.unification_
|
|
|
360
352
|
const _1 = definition_;
|
|
361
353
|
{
|
|
362
354
|
const _c = _1;
|
|
363
|
-
return ff_compiler_Syntax.DFunction(_c.at_, _c.signature_,
|
|
364
|
-
return ff_compiler_Inference.Inference_inferLambda(self_, environment2_, functionType_, _w1)
|
|
365
|
-
})))
|
|
366
|
-
return
|
|
355
|
+
return ff_compiler_Syntax.DFunction(_c.at_, _c.signature_, ff_compiler_Inference.Inference_inferLambda(self_, environment2_, functionType_, definition_.body_))
|
|
367
356
|
}
|
|
368
357
|
}
|
|
369
358
|
}))
|
|
@@ -561,7 +550,7 @@ return ff_compiler_Syntax.TConstructor(p_.at_, _c.name_, _c.generics_)
|
|
|
561
550
|
}
|
|
562
551
|
return
|
|
563
552
|
}
|
|
564
|
-
|
|
553
|
+
{
|
|
565
554
|
const t_ = _1;
|
|
566
555
|
{
|
|
567
556
|
const _1 = t_;
|
|
@@ -600,7 +589,7 @@ const headVariables_ = ff_compiler_Inference.Inference_inferPattern(self_, envir
|
|
|
600
589
|
const tailVariables_ = ff_compiler_Inference.Inference_inferPattern(self_, environment_, listType_, tail_);
|
|
601
590
|
return ff_core_Map.Map_addAll(headVariables_, tailVariables_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
|
|
602
591
|
}
|
|
603
|
-
|
|
592
|
+
{
|
|
604
593
|
const at_ = _1.at_;
|
|
605
594
|
const name_ = _1.name_;
|
|
606
595
|
const patterns_ = _1.patterns_;
|
|
@@ -669,10 +658,12 @@ if(_1.EField) {
|
|
|
669
658
|
const e_ = _1;
|
|
670
659
|
const recordType_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, e_.at_);
|
|
671
660
|
if(ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, term_.at_)) {
|
|
672
|
-
|
|
673
|
-
const
|
|
661
|
+
{
|
|
662
|
+
const if_o = hookRecordTypeBox_
|
|
663
|
+
if(if_o.Some) {
|
|
664
|
+
const _w1 = if_o.value_;
|
|
674
665
|
_w1.value_ = ff_core_Option.Some(recordType_)
|
|
675
|
-
|
|
666
|
+
}
|
|
676
667
|
}
|
|
677
668
|
};
|
|
678
669
|
const record_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, recordType_, e_.record_);
|
|
@@ -706,7 +697,7 @@ return (_w1.second_ === e_.field_)
|
|
|
706
697
|
})), ((_w1) => {
|
|
707
698
|
return _w1.first_
|
|
708
699
|
})), ((index_) => {
|
|
709
|
-
const t1_ = (typeArguments_[index_] ?? ff_core_List.
|
|
700
|
+
const t1_ = (typeArguments_[index_] ?? ff_core_List.List_grab(typeArguments_, index_));
|
|
710
701
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t1_);
|
|
711
702
|
{
|
|
712
703
|
const _1 = e_;
|
|
@@ -739,7 +730,7 @@ if((!instantiated_.scheme_.isVariable_)) {
|
|
|
739
730
|
const signature_ = (((_c) => {
|
|
740
731
|
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_)
|
|
741
732
|
}))(instantiated_.scheme_.signature_);
|
|
742
|
-
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, recordType_, (instantiated_.scheme_.signature_.parameters_[0] ?? ff_core_List.
|
|
733
|
+
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, recordType_, (instantiated_.scheme_.signature_.parameters_[0] ?? ff_core_List.List_grab(instantiated_.scheme_.signature_.parameters_, 0)).valueType_);
|
|
743
734
|
return ff_compiler_Inference.Inference_inferEtaExpansion(self_, environment_, expected_, e_.at_, signature_, term_)
|
|
744
735
|
}
|
|
745
736
|
}
|
|
@@ -755,7 +746,7 @@ return ff_compiler_Syntax.EField(_c.at_, instantiated_.scheme_.isNewtype_, recor
|
|
|
755
746
|
}
|
|
756
747
|
return
|
|
757
748
|
}
|
|
758
|
-
|
|
749
|
+
{
|
|
759
750
|
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)})
|
|
760
751
|
}
|
|
761
752
|
}
|
|
@@ -764,7 +755,7 @@ return
|
|
|
764
755
|
if(_1.TVariable && ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
|
|
765
756
|
return term_
|
|
766
757
|
}
|
|
767
|
-
|
|
758
|
+
{
|
|
768
759
|
const index_ = _1.index_;
|
|
769
760
|
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)})
|
|
770
761
|
}
|
|
@@ -1004,7 +995,6 @@ break
|
|
|
1004
995
|
}
|
|
1005
996
|
{
|
|
1006
997
|
|
|
1007
|
-
break
|
|
1008
998
|
}
|
|
1009
999
|
} while(false);
|
|
1010
1000
|
const lambda_ = ff_compiler_Inference.Inference_inferLambda(self_, environment_, expected_, l_);
|
|
@@ -1068,10 +1058,9 @@ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Sy
|
|
|
1068
1058
|
};
|
|
1069
1059
|
const signature_ = scheme_.signature_;
|
|
1070
1060
|
if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
const
|
|
1074
|
-
const a_ = _1.second_;
|
|
1061
|
+
for(let for_a = e_.arguments_, for_i = 0, for_l = for_a.length; for_i < for_l; for_i++) {
|
|
1062
|
+
const i_ = for_i;
|
|
1063
|
+
const a_ = for_a[for_i];
|
|
1075
1064
|
const p_ = ff_core_List.List_find(signature_.parameters_, ((_w1) => {
|
|
1076
1065
|
return (_w1.name_ === a_.name_)
|
|
1077
1066
|
}));
|
|
@@ -1089,9 +1078,7 @@ return ff_compiler_Syntax.Argument(_c.at_, ff_core_Option.Some(f_.name_), _c.val
|
|
|
1089
1078
|
}));
|
|
1090
1079
|
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.InferArgumentHook(self_.unification_, environment_, true, term_.at_, e_.name_, signature_.parameters_, arguments_, i_))
|
|
1091
1080
|
}
|
|
1092
|
-
return
|
|
1093
1081
|
}
|
|
1094
|
-
}))
|
|
1095
1082
|
};
|
|
1096
1083
|
const parameterNames_ = ff_core_List.List_map(signature_.parameters_, ((_w1) => {
|
|
1097
1084
|
return _w1.name_
|
|
@@ -1166,7 +1153,7 @@ tailCall_: call_.tailCall_
|
|
|
1166
1153
|
}
|
|
1167
1154
|
return
|
|
1168
1155
|
}
|
|
1169
|
-
|
|
1156
|
+
{
|
|
1170
1157
|
return ff_compiler_Inference.fail_(e_.at_, "Internal error: Static calls not expected in the Inference phase")
|
|
1171
1158
|
}
|
|
1172
1159
|
}))(e_.target_);
|
|
@@ -1192,7 +1179,7 @@ return ff_compiler_Inference.Inference_inferFunctionCall(self_, environment_, ex
|
|
|
1192
1179
|
}
|
|
1193
1180
|
return
|
|
1194
1181
|
}
|
|
1195
|
-
|
|
1182
|
+
{
|
|
1196
1183
|
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)})
|
|
1197
1184
|
}
|
|
1198
1185
|
}
|
|
@@ -1203,10 +1190,12 @@ if(_1.EField) {
|
|
|
1203
1190
|
const f_ = _1;
|
|
1204
1191
|
const recordType_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, f_.at_);
|
|
1205
1192
|
if(ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, term_.at_)) {
|
|
1206
|
-
|
|
1207
|
-
const
|
|
1193
|
+
{
|
|
1194
|
+
const if_o = hookRecordTypeBox_
|
|
1195
|
+
if(if_o.Some) {
|
|
1196
|
+
const _w1 = if_o.value_;
|
|
1208
1197
|
_w1.value_ = ff_core_Option.Some(recordType_)
|
|
1209
|
-
|
|
1198
|
+
}
|
|
1210
1199
|
}
|
|
1211
1200
|
};
|
|
1212
1201
|
const record_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, recordType_, f_.record_);
|
|
@@ -1236,7 +1225,7 @@ if(_1.Some) {
|
|
|
1236
1225
|
const instantiated_ = _1.value_;
|
|
1237
1226
|
return ff_compiler_Inference.Inference_inferLambdaCall(self_, environment_, expected_, e2_)
|
|
1238
1227
|
}
|
|
1239
|
-
|
|
1228
|
+
{
|
|
1240
1229
|
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)})
|
|
1241
1230
|
}
|
|
1242
1231
|
}
|
|
@@ -1245,7 +1234,7 @@ return
|
|
|
1245
1234
|
if(_1.TVariable && ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
|
|
1246
1235
|
return ff_compiler_Inference.Inference_inferLambdaCall(self_, environment_, expected_, e2_)
|
|
1247
1236
|
}
|
|
1248
|
-
|
|
1237
|
+
{
|
|
1249
1238
|
const index_ = _1.index_;
|
|
1250
1239
|
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)})
|
|
1251
1240
|
}
|
|
@@ -1331,7 +1320,7 @@ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Sy
|
|
|
1331
1320
|
}))
|
|
1332
1321
|
return
|
|
1333
1322
|
}
|
|
1334
|
-
|
|
1323
|
+
{
|
|
1335
1324
|
const e_ = _1;
|
|
1336
1325
|
const recordType_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, e_.at_);
|
|
1337
1326
|
const record_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, recordType_, e_.record_);
|
|
@@ -1370,7 +1359,7 @@ if(_1.Some) {
|
|
|
1370
1359
|
const instantiated_ = _1.value_;
|
|
1371
1360
|
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)})
|
|
1372
1361
|
}
|
|
1373
|
-
|
|
1362
|
+
{
|
|
1374
1363
|
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)})
|
|
1375
1364
|
}
|
|
1376
1365
|
}
|
|
@@ -1379,7 +1368,7 @@ return
|
|
|
1379
1368
|
if(_1.TVariable && ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
|
|
1380
1369
|
return term_
|
|
1381
1370
|
}
|
|
1382
|
-
|
|
1371
|
+
{
|
|
1383
1372
|
const index_ = _1.index_;
|
|
1384
1373
|
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)})
|
|
1385
1374
|
}
|
|
@@ -1391,12 +1380,24 @@ return
|
|
|
1391
1380
|
|
|
1392
1381
|
export function Inference_inferAssignment(self_, environment_, expected_, at_, operator_, value_, signature_) {
|
|
1393
1382
|
const t_ = signature_.returnType_;
|
|
1394
|
-
|
|
1383
|
+
const newValue_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, t_, value_);
|
|
1384
|
+
if(((((operator_ === "+") || (operator_ === "-")) || (operator_ === "*")) || (operator_ === "/"))) {
|
|
1385
|
+
do {
|
|
1386
|
+
const _1 = ff_compiler_Unification.Unification_substitute(self_.unification_, t_);
|
|
1387
|
+
if(_1.TConstructor) {
|
|
1388
|
+
const name_ = _1.name_;
|
|
1389
|
+
if(((((name_ === ff_compiler_Inference.core_("Int")) || (name_ === ff_compiler_Inference.core_("Float"))) || (name_ === ff_compiler_Inference.core_("JsValue"))) || ((name_ === ff_compiler_Inference.core_("String")) && (operator_ === "+")))) {
|
|
1390
|
+
|
|
1391
|
+
break
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
{
|
|
1395
1395
|
ff_compiler_Unification.Unification_unify(self_.unification_, at_, t_, ff_compiler_Syntax.TConstructor(at_, ff_compiler_Inference.core_("Int"), []))
|
|
1396
|
+
}
|
|
1397
|
+
} while(false)
|
|
1396
1398
|
} else if((operator_ !== "")) {
|
|
1397
|
-
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, (("Only +=,
|
|
1399
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, (("Only +=, -=, *=, /= and = assignments are supported. Got: " + operator_) + "=")), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
1398
1400
|
} else {};
|
|
1399
|
-
const newValue_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, t_, value_);
|
|
1400
1401
|
ff_compiler_Unification.Unification_unify(self_.unification_, at_, expected_, ff_compiler_Syntax.TConstructor(at_, ff_compiler_Inference.core_("Unit"), []));
|
|
1401
1402
|
return newValue_
|
|
1402
1403
|
}
|
|
@@ -1411,7 +1412,7 @@ if(_1.DynamicCall) {
|
|
|
1411
1412
|
const call_ = _1;
|
|
1412
1413
|
return call_.tailCall_
|
|
1413
1414
|
}
|
|
1414
|
-
|
|
1415
|
+
{
|
|
1415
1416
|
return ff_compiler_Inference.fail_(e_.at_, "Internal error: Static calls not expected in inferMethodCall")
|
|
1416
1417
|
}
|
|
1417
1418
|
}))(e_.target_);
|
|
@@ -1444,23 +1445,41 @@ export function Inference_inferFunctionCall(self_, environment_, expected_, sign
|
|
|
1444
1445
|
const _1 = term_;
|
|
1445
1446
|
if(_1.ECall) {
|
|
1446
1447
|
const e_ = _1;
|
|
1448
|
+
let isUnsafeJsAwaitCall_ = false;
|
|
1447
1449
|
const tailCall_ = (((_1) => {
|
|
1448
1450
|
if(_1.DynamicCall) {
|
|
1449
1451
|
const call_ = _1;
|
|
1452
|
+
do {
|
|
1453
|
+
const _1 = call_.function_;
|
|
1454
|
+
if(_1.EVariable && _1.name_ === "ff:core/Js.await") {
|
|
1455
|
+
isUnsafeJsAwaitCall_ = true
|
|
1456
|
+
break
|
|
1457
|
+
}
|
|
1458
|
+
if(_1.EVariable && _1.name_ === "ff:core/Js.awaitCancellablePromise") {
|
|
1459
|
+
isUnsafeJsAwaitCall_ = true
|
|
1460
|
+
break
|
|
1461
|
+
}
|
|
1462
|
+
{
|
|
1463
|
+
|
|
1464
|
+
}
|
|
1465
|
+
} while(false);
|
|
1450
1466
|
return call_.tailCall_
|
|
1451
1467
|
}
|
|
1452
|
-
|
|
1468
|
+
{
|
|
1453
1469
|
return ff_compiler_Inference.fail_(e_.at_, "Internal error: Static calls not expected in inferFunctionCall")
|
|
1454
1470
|
}
|
|
1455
1471
|
}))(e_.target_);
|
|
1456
1472
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, signature_.returnType_);
|
|
1457
1473
|
const arguments_ = ff_compiler_Inference.Inference_inferArguments(self_, e_.at_, name_, environment_, signature_.parameters_, e_.arguments_);
|
|
1458
|
-
|
|
1474
|
+
const effect_ = (isUnsafeJsAwaitCall_
|
|
1475
|
+
? ff_compiler_Syntax.TConstructor(term_.at_, "Q$", [])
|
|
1476
|
+
: signature_.effect_);
|
|
1477
|
+
ff_compiler_Unification.Unification_affect(self_.unification_, term_.at_, effect_, environment_.effect_);
|
|
1459
1478
|
{
|
|
1460
1479
|
const _1 = e_;
|
|
1461
1480
|
{
|
|
1462
1481
|
const _c = _1;
|
|
1463
|
-
return ff_compiler_Syntax.ECall(_c.at_, ff_compiler_Syntax.StaticCall(name_, tailCall_, instanceCall_),
|
|
1482
|
+
return ff_compiler_Syntax.ECall(_c.at_, ff_compiler_Syntax.StaticCall(name_, tailCall_, instanceCall_), effect_, ff_core_List.List_map(instantiation_, ((_w1) => {
|
|
1464
1483
|
return _w1.second_
|
|
1465
1484
|
})), arguments_, _c.dictionaries_)
|
|
1466
1485
|
return
|
|
@@ -1493,7 +1512,7 @@ return
|
|
|
1493
1512
|
if(_1.DynamicCall) {
|
|
1494
1513
|
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)})
|
|
1495
1514
|
}
|
|
1496
|
-
|
|
1515
|
+
{
|
|
1497
1516
|
return ff_compiler_Inference.fail_(e_.at_, "Internal error: Static calls not expected in inferLambdaCall")
|
|
1498
1517
|
}
|
|
1499
1518
|
}))(e_.target_);
|
|
@@ -1507,10 +1526,12 @@ const arguments_ = ff_core_List.List_map(ff_core_List.List_zip(e_.arguments_, ar
|
|
|
1507
1526
|
{
|
|
1508
1527
|
const argument_ = _1.first_;
|
|
1509
1528
|
const t_ = _1.second_;
|
|
1510
|
-
|
|
1511
|
-
const
|
|
1529
|
+
{
|
|
1530
|
+
const if_o = argument_.name_
|
|
1531
|
+
if(if_o.Some) {
|
|
1532
|
+
const name_ = if_o.value_;
|
|
1512
1533
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(argument_.at_, ("Named argument not allowed here: " + name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
1513
|
-
|
|
1534
|
+
}
|
|
1514
1535
|
};
|
|
1515
1536
|
{
|
|
1516
1537
|
const _1 = argument_;
|
|
@@ -1522,10 +1543,12 @@ return ff_compiler_Syntax.Argument(_c.at_, _c.name_, ff_compiler_Inference.Infer
|
|
|
1522
1543
|
return
|
|
1523
1544
|
}
|
|
1524
1545
|
}));
|
|
1525
|
-
|
|
1526
|
-
const
|
|
1546
|
+
{
|
|
1547
|
+
const if_o = ff_core_List.List_first(e_.typeArguments_)
|
|
1548
|
+
if(if_o.Some) {
|
|
1549
|
+
const typeArgument_ = if_o.value_;
|
|
1527
1550
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(typeArgument_.at_, "Type arguments not allowed here"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
1528
|
-
|
|
1551
|
+
}
|
|
1529
1552
|
};
|
|
1530
1553
|
ff_compiler_Unification.Unification_affect(self_.unification_, term_.at_, effect_, environment_.effect_);
|
|
1531
1554
|
{
|
|
@@ -1723,6 +1746,12 @@ const magic_ = ((t_) => {
|
|
|
1723
1746
|
const _1 = ff_compiler_Unification.Unification_substitute(self_.unification_, t_);
|
|
1724
1747
|
if(_1.TConstructor && _1.generics_.length === 0) {
|
|
1725
1748
|
const name_ = _1.name_;
|
|
1749
|
+
if((name_ === ff_compiler_Inference.core_("JsValue"))) {
|
|
1750
|
+
return ff_core_Option.Some("JsValue")
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
if(_1.TConstructor && _1.generics_.length === 0) {
|
|
1754
|
+
const name_ = _1.name_;
|
|
1726
1755
|
if((name_ === ff_compiler_Inference.core_("Float"))) {
|
|
1727
1756
|
return ff_core_Option.Some("Float")
|
|
1728
1757
|
}
|
|
@@ -1745,6 +1774,16 @@ return ff_core_Option.None()
|
|
|
1745
1774
|
}
|
|
1746
1775
|
});
|
|
1747
1776
|
const chooseType_ = ((_1, _2) => {
|
|
1777
|
+
if(_1.Some && _1.value_ === "JsValue") {
|
|
1778
|
+
ff_compiler_Unification.Unification_unify(self_.unification_, e2_.at_, t1_, t2_);
|
|
1779
|
+
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t1_)
|
|
1780
|
+
return
|
|
1781
|
+
}
|
|
1782
|
+
if(_2.Some && _2.value_ === "JsValue") {
|
|
1783
|
+
ff_compiler_Unification.Unification_unify(self_.unification_, e1_.at_, t2_, t1_);
|
|
1784
|
+
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t2_)
|
|
1785
|
+
return
|
|
1786
|
+
}
|
|
1748
1787
|
if(_1.Some && _1.value_ === "String" && _2.Some) {
|
|
1749
1788
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t1_)
|
|
1750
1789
|
return
|
|
@@ -1770,12 +1809,12 @@ ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_,
|
|
|
1770
1809
|
return
|
|
1771
1810
|
}
|
|
1772
1811
|
if(_1.Some && _2.None) {
|
|
1773
|
-
ff_compiler_Unification.Unification_unify(self_.unification_,
|
|
1812
|
+
ff_compiler_Unification.Unification_unify(self_.unification_, e2_.at_, t1_, t2_);
|
|
1774
1813
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t1_)
|
|
1775
1814
|
return
|
|
1776
1815
|
}
|
|
1777
1816
|
if(_1.None && _2.Some) {
|
|
1778
|
-
ff_compiler_Unification.Unification_unify(self_.unification_,
|
|
1817
|
+
ff_compiler_Unification.Unification_unify(self_.unification_, e1_.at_, t2_, t1_);
|
|
1779
1818
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t2_)
|
|
1780
1819
|
return
|
|
1781
1820
|
}
|
|
@@ -1786,7 +1825,7 @@ return
|
|
|
1786
1825
|
if(_1.Some && _2.Some) {
|
|
1787
1826
|
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)})
|
|
1788
1827
|
}
|
|
1789
|
-
|
|
1828
|
+
{
|
|
1790
1829
|
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)})
|
|
1791
1830
|
}
|
|
1792
1831
|
});
|
|
@@ -1842,10 +1881,9 @@ return ff_compiler_Environment.Environment(_c.modulePrefix_, _c.symbols_, _c.tra
|
|
|
1842
1881
|
|
|
1843
1882
|
export function Inference_inferArguments(self_, callAt_, callName_, environment_, parameters_, arguments_) {
|
|
1844
1883
|
if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
const
|
|
1848
|
-
const a_ = _1.second_;
|
|
1884
|
+
for(let for_a = arguments_, for_i = 0, for_l = for_a.length; for_i < for_l; for_i++) {
|
|
1885
|
+
const i_ = for_i;
|
|
1886
|
+
const a_ = for_a[for_i];
|
|
1849
1887
|
const p_ = ff_core_List.List_find(parameters_, ((p_) => {
|
|
1850
1888
|
return ff_core_Option.Option_any(a_.name_, ((_w1) => {
|
|
1851
1889
|
return (_w1 === p_.name_)
|
|
@@ -1856,9 +1894,7 @@ return ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, _w1.at_)
|
|
|
1856
1894
|
})))) {
|
|
1857
1895
|
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.InferArgumentHook(self_.unification_, environment_, false, callAt_, callName_, parameters_, arguments_, i_))
|
|
1858
1896
|
}
|
|
1859
|
-
return
|
|
1860
1897
|
}
|
|
1861
|
-
}))
|
|
1862
1898
|
};
|
|
1863
1899
|
let remainingArguments_ = ff_core_List.List_toArray(arguments_);
|
|
1864
1900
|
ff_core_Array.Array_reverse(remainingArguments_);
|
|
@@ -1889,12 +1925,14 @@ return ff_core_Option.Option_contains(_w1.name_, p_.name_, ff_core_Equal.ff_core
|
|
|
1889
1925
|
{
|
|
1890
1926
|
const at_ = _1.at_;
|
|
1891
1927
|
const e_ = _1.value_;
|
|
1892
|
-
|
|
1928
|
+
{
|
|
1929
|
+
const if_o = ff_core_Array.Array_indexWhere(remainingArguments_, ((_w1) => {
|
|
1893
1930
|
return ff_core_Option.Option_contains(_w1.name_, p_.name_, ff_core_Equal.ff_core_Equal_Equal$ff_core_String_String)
|
|
1894
|
-
}))
|
|
1895
|
-
|
|
1931
|
+
}))
|
|
1932
|
+
if(if_o.Some) {
|
|
1933
|
+
const _w1 = if_o.value_;
|
|
1896
1934
|
ff_core_Array.Array_delete(remainingArguments_, _w1, 1)
|
|
1897
|
-
|
|
1935
|
+
}
|
|
1898
1936
|
};
|
|
1899
1937
|
const e2_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, t_, e_);
|
|
1900
1938
|
return ff_compiler_Syntax.Argument(at_, ff_core_Option.Some(p_.name_), e2_)
|
|
@@ -1911,7 +1949,7 @@ const callAt_ = _1.at_;
|
|
|
1911
1949
|
ff_compiler_Inference.fail_(callAt_, "Too many arguments")
|
|
1912
1950
|
return
|
|
1913
1951
|
}
|
|
1914
|
-
|
|
1952
|
+
{
|
|
1915
1953
|
const callAt_ = _1.at_;
|
|
1916
1954
|
const n_ = _1.name_.value_;
|
|
1917
1955
|
ff_compiler_Inference.fail_(callAt_, ("Unknown argument: " + n_))
|
|
@@ -1993,7 +2031,7 @@ return ff_compiler_Syntax.Parameter(_c.at_, _c.mutable_, _c.name_, ff_compiler_U
|
|
|
1993
2031
|
}));
|
|
1994
2032
|
const returnType_ = ff_compiler_Unification.Unification_instantiate(self_.unification_, instantiationMap_, scheme_.signature_.returnType_);
|
|
1995
2033
|
const effect_ = ff_compiler_Unification.Unification_instantiate(self_.unification_, instantiationMap_, scheme_.signature_.effect_);
|
|
1996
|
-
for(let
|
|
2034
|
+
for(let for_a = scheme_.signature_.constraints_, for_i = 0, for_l = for_a.length; for_i < for_l; for_i++) {
|
|
1997
2035
|
const c_ = for_a[for_i];
|
|
1998
2036
|
const generics_ = ff_core_List.List_map(c_.generics_, ((_w1) => {
|
|
1999
2037
|
return ff_compiler_Unification.Unification_instantiate(self_.unification_, instantiationMap_, _w1)
|
|
@@ -2079,7 +2117,7 @@ if((traitDefinition_.generics_.length !== definition_.typeArguments_.length)) {
|
|
|
2079
2117
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(definition_.at_, ((((("Wrong number of type arguments for " + traitName_) + ", expected ") + (traitDefinition_.generics_.length - 1)) + ", got ") + (definition_.typeArguments_.length - 1))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
2080
2118
|
};
|
|
2081
2119
|
const instantiationMap_ = ff_core_List.List_toMap(ff_core_List.List_zip(traitDefinition_.generics_, definition_.typeArguments_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
2082
|
-
for(let
|
|
2120
|
+
for(let for_a = traitDefinition_.methods_, for_i = 0, for_l = for_a.length; for_i < for_l; for_i++) {
|
|
2083
2121
|
const traitMethod_ = for_a[for_i];
|
|
2084
2122
|
const found_ = ff_core_List.List_filter(definition_.methods_, ((_w1) => {
|
|
2085
2123
|
return (_w1.signature_.name_ === traitMethod_.name_)
|
|
@@ -2087,7 +2125,7 @@ return (_w1.signature_.name_ === traitMethod_.name_)
|
|
|
2087
2125
|
if(ff_core_List.List_isEmpty(found_)) {
|
|
2088
2126
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(definition_.at_, ("Missing instance method: " + traitMethod_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
2089
2127
|
};
|
|
2090
|
-
for(let
|
|
2128
|
+
for(let for_a = found_, for_i = 1, for_l = for_a.length; for_i < for_l; for_i++) {
|
|
2091
2129
|
const duplicateMethod_ = for_a[for_i];
|
|
2092
2130
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(duplicateMethod_.at_, ("Duplicated instance method: " + traitMethod_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
2093
2131
|
}
|
|
@@ -2114,22 +2152,19 @@ return ff_compiler_Syntax.Parameter(_c.at_, _c.mutable_, _c.name_, ff_compiler_U
|
|
|
2114
2152
|
}
|
|
2115
2153
|
}));
|
|
2116
2154
|
const returnType_ = ff_compiler_Unification.Unification_instantiate(self_.unification_, instantiationMap_, traitMethodScheme_.signature_.returnType_);
|
|
2117
|
-
for(let for_i = Math.max(parameters_.length, 0),
|
|
2155
|
+
for(let for_a = instanceFunction_.signature_.parameters_, for_i = Math.max(parameters_.length, 0), for_l = for_a.length; for_i < for_l; for_i++) {
|
|
2118
2156
|
const instanceParameter_ = for_a[for_i];
|
|
2119
2157
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(instanceParameter_.at_, ("Unexpected parameter: " + instanceParameter_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
2120
2158
|
};
|
|
2121
|
-
for(let for_i = Math.max(instanceFunction_.signature_.parameters_.length, 0),
|
|
2159
|
+
for(let for_a = parameters_, for_i = Math.max(instanceFunction_.signature_.parameters_.length, 0), for_l = for_a.length; for_i < for_l; for_i++) {
|
|
2122
2160
|
const traitParameter_ = for_a[for_i];
|
|
2123
2161
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(instanceFunction_.at_, ("Missing parameter: " + traitParameter_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
2124
2162
|
};
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
const
|
|
2128
|
-
const instanceParameter_ = _1.second_;
|
|
2163
|
+
for(let for_a = parameters_, for_i = 0, for_l = for_a.length, for_a2 = instanceFunction_.signature_.parameters_, for_i2 = 0, for_l2 = for_a2.length; for_i < for_l && for_i2 < for_l2; for_i++, for_i2++) {
|
|
2164
|
+
const traitParameter_ = for_a[for_i];
|
|
2165
|
+
const instanceParameter_ = for_a2[for_i2];
|
|
2129
2166
|
ff_compiler_Unification.Unification_unify(self_.unification_, instanceParameter_.valueType_.at_, traitParameter_.valueType_, instanceParameter_.valueType_)
|
|
2130
|
-
|
|
2131
|
-
}
|
|
2132
|
-
}));
|
|
2167
|
+
};
|
|
2133
2168
|
ff_compiler_Unification.Unification_unify(self_.unification_, instanceFunction_.signature_.returnType_.at_, returnType_, instanceFunction_.signature_.returnType_);
|
|
2134
2169
|
if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, instanceFunction_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, traitMethodScheme_.signature_.at_))) {
|
|
2135
2170
|
const symbolHook_ = ff_compiler_LspHook.SymbolHook(instanceFunction_.signature_.name_, instanceFunction_.at_, traitMethodScheme_.signature_.at_);
|
|
@@ -2162,12 +2197,8 @@ const functions_ = ff_core_List.List_map(definition_.methods_, ((method_) => {
|
|
|
2162
2197
|
const signature_ = (((_c) => {
|
|
2163
2198
|
return ff_compiler_Syntax.Signature(_c.at_, _c.name_, _c.member_, [...definition_.generics_, ...method_.signature_.generics_], [...definition_.constraints_, ...method_.signature_.constraints_], [selfParameter_, ...method_.signature_.parameters_], _c.returnType_, _c.effect_)
|
|
2164
2199
|
}))(method_.signature_);
|
|
2165
|
-
const body_ =
|
|
2166
|
-
{
|
|
2167
|
-
const _1 = lambda_;
|
|
2168
|
-
{
|
|
2169
|
-
const _c = _1;
|
|
2170
|
-
return ff_compiler_Syntax.Lambda(_c.at_, _c.effect_, ff_core_List.List_map(lambda_.cases_, ((case_) => {
|
|
2200
|
+
const body_ = (((_c) => {
|
|
2201
|
+
return ff_compiler_Syntax.Lambda(_c.at_, _c.effect_, ff_core_List.List_map(method_.body_.cases_, ((case_) => {
|
|
2171
2202
|
{
|
|
2172
2203
|
const _1 = case_;
|
|
2173
2204
|
{
|
|
@@ -2176,10 +2207,7 @@ return ff_compiler_Syntax.MatchCase(_c.at_, [ff_compiler_Syntax.PVariable(method
|
|
|
2176
2207
|
}
|
|
2177
2208
|
}
|
|
2178
2209
|
})))
|
|
2179
|
-
|
|
2180
|
-
}
|
|
2181
|
-
}
|
|
2182
|
-
}));
|
|
2210
|
+
}))(method_.body_);
|
|
2183
2211
|
const function_ = (((_c) => {
|
|
2184
2212
|
return ff_compiler_Syntax.DFunction(_c.at_, signature_, body_)
|
|
2185
2213
|
}))(method_);
|
|
@@ -2222,10 +2250,7 @@ return ff_compiler_Unification.Unification_withLocalInstances(self_.unification_
|
|
|
2222
2250
|
const _1 = definition_;
|
|
2223
2251
|
{
|
|
2224
2252
|
const _c = _1;
|
|
2225
|
-
return ff_compiler_Syntax.DFunction(_c.at_, _c.signature_,
|
|
2226
|
-
return ff_compiler_Inference.Inference_inferLambda(self_, environment2_, functionType_, _w1)
|
|
2227
|
-
})))
|
|
2228
|
-
return
|
|
2253
|
+
return ff_compiler_Syntax.DFunction(_c.at_, _c.signature_, ff_compiler_Inference.Inference_inferLambda(self_, environment2_, functionType_, definition_.body_))
|
|
2229
2254
|
}
|
|
2230
2255
|
}
|
|
2231
2256
|
}))
|
|
@@ -2423,7 +2448,7 @@ return ff_compiler_Syntax.TConstructor(p_.at_, _c.name_, _c.generics_)
|
|
|
2423
2448
|
}
|
|
2424
2449
|
return
|
|
2425
2450
|
}
|
|
2426
|
-
|
|
2451
|
+
{
|
|
2427
2452
|
const t_ = _1;
|
|
2428
2453
|
{
|
|
2429
2454
|
const _1 = t_;
|
|
@@ -2462,7 +2487,7 @@ const headVariables_ = ff_compiler_Inference.Inference_inferPattern(self_, envir
|
|
|
2462
2487
|
const tailVariables_ = ff_compiler_Inference.Inference_inferPattern(self_, environment_, listType_, tail_);
|
|
2463
2488
|
return ff_core_Map.Map_addAll(headVariables_, tailVariables_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
|
|
2464
2489
|
}
|
|
2465
|
-
|
|
2490
|
+
{
|
|
2466
2491
|
const at_ = _1.at_;
|
|
2467
2492
|
const name_ = _1.name_;
|
|
2468
2493
|
const patterns_ = _1.patterns_;
|
|
@@ -2531,10 +2556,12 @@ if(_1.EField) {
|
|
|
2531
2556
|
const e_ = _1;
|
|
2532
2557
|
const recordType_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, e_.at_);
|
|
2533
2558
|
if(ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, term_.at_)) {
|
|
2534
|
-
|
|
2535
|
-
const
|
|
2559
|
+
{
|
|
2560
|
+
const if_o = hookRecordTypeBox_
|
|
2561
|
+
if(if_o.Some) {
|
|
2562
|
+
const _w1 = if_o.value_;
|
|
2536
2563
|
_w1.value_ = ff_core_Option.Some(recordType_)
|
|
2537
|
-
|
|
2564
|
+
}
|
|
2538
2565
|
}
|
|
2539
2566
|
};
|
|
2540
2567
|
const record_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, recordType_, e_.record_);
|
|
@@ -2568,7 +2595,7 @@ return (_w1.second_ === e_.field_)
|
|
|
2568
2595
|
})), ((_w1) => {
|
|
2569
2596
|
return _w1.first_
|
|
2570
2597
|
})), ((index_) => {
|
|
2571
|
-
const t1_ = (typeArguments_[index_] ?? ff_core_List.
|
|
2598
|
+
const t1_ = (typeArguments_[index_] ?? ff_core_List.List_grab(typeArguments_, index_));
|
|
2572
2599
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t1_);
|
|
2573
2600
|
{
|
|
2574
2601
|
const _1 = e_;
|
|
@@ -2601,7 +2628,7 @@ if((!instantiated_.scheme_.isVariable_)) {
|
|
|
2601
2628
|
const signature_ = (((_c) => {
|
|
2602
2629
|
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_)
|
|
2603
2630
|
}))(instantiated_.scheme_.signature_);
|
|
2604
|
-
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, recordType_, (instantiated_.scheme_.signature_.parameters_[0] ?? ff_core_List.
|
|
2631
|
+
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, recordType_, (instantiated_.scheme_.signature_.parameters_[0] ?? ff_core_List.List_grab(instantiated_.scheme_.signature_.parameters_, 0)).valueType_);
|
|
2605
2632
|
return ff_compiler_Inference.Inference_inferEtaExpansion(self_, environment_, expected_, e_.at_, signature_, term_)
|
|
2606
2633
|
}
|
|
2607
2634
|
}
|
|
@@ -2617,7 +2644,7 @@ return ff_compiler_Syntax.EField(_c.at_, instantiated_.scheme_.isNewtype_, recor
|
|
|
2617
2644
|
}
|
|
2618
2645
|
return
|
|
2619
2646
|
}
|
|
2620
|
-
|
|
2647
|
+
{
|
|
2621
2648
|
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)})
|
|
2622
2649
|
}
|
|
2623
2650
|
}
|
|
@@ -2626,7 +2653,7 @@ return
|
|
|
2626
2653
|
if(_1.TVariable && ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
|
|
2627
2654
|
return term_
|
|
2628
2655
|
}
|
|
2629
|
-
|
|
2656
|
+
{
|
|
2630
2657
|
const index_ = _1.index_;
|
|
2631
2658
|
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)})
|
|
2632
2659
|
}
|
|
@@ -2866,7 +2893,6 @@ break
|
|
|
2866
2893
|
}
|
|
2867
2894
|
{
|
|
2868
2895
|
|
|
2869
|
-
break
|
|
2870
2896
|
}
|
|
2871
2897
|
} while(false);
|
|
2872
2898
|
const lambda_ = ff_compiler_Inference.Inference_inferLambda(self_, environment_, expected_, l_);
|
|
@@ -2930,10 +2956,9 @@ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Sy
|
|
|
2930
2956
|
};
|
|
2931
2957
|
const signature_ = scheme_.signature_;
|
|
2932
2958
|
if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
const
|
|
2936
|
-
const a_ = _1.second_;
|
|
2959
|
+
for(let for_a = e_.arguments_, for_i = 0, for_l = for_a.length; for_i < for_l; for_i++) {
|
|
2960
|
+
const i_ = for_i;
|
|
2961
|
+
const a_ = for_a[for_i];
|
|
2937
2962
|
const p_ = ff_core_List.List_find(signature_.parameters_, ((_w1) => {
|
|
2938
2963
|
return (_w1.name_ === a_.name_)
|
|
2939
2964
|
}));
|
|
@@ -2951,9 +2976,7 @@ return ff_compiler_Syntax.Argument(_c.at_, ff_core_Option.Some(f_.name_), _c.val
|
|
|
2951
2976
|
}));
|
|
2952
2977
|
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.InferArgumentHook(self_.unification_, environment_, true, term_.at_, e_.name_, signature_.parameters_, arguments_, i_))
|
|
2953
2978
|
}
|
|
2954
|
-
return
|
|
2955
2979
|
}
|
|
2956
|
-
}))
|
|
2957
2980
|
};
|
|
2958
2981
|
const parameterNames_ = ff_core_List.List_map(signature_.parameters_, ((_w1) => {
|
|
2959
2982
|
return _w1.name_
|
|
@@ -3028,7 +3051,7 @@ tailCall_: call_.tailCall_
|
|
|
3028
3051
|
}
|
|
3029
3052
|
return
|
|
3030
3053
|
}
|
|
3031
|
-
|
|
3054
|
+
{
|
|
3032
3055
|
return ff_compiler_Inference.fail_(e_.at_, "Internal error: Static calls not expected in the Inference phase")
|
|
3033
3056
|
}
|
|
3034
3057
|
}))(e_.target_);
|
|
@@ -3054,7 +3077,7 @@ return ff_compiler_Inference.Inference_inferFunctionCall(self_, environment_, ex
|
|
|
3054
3077
|
}
|
|
3055
3078
|
return
|
|
3056
3079
|
}
|
|
3057
|
-
|
|
3080
|
+
{
|
|
3058
3081
|
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)})
|
|
3059
3082
|
}
|
|
3060
3083
|
}
|
|
@@ -3065,10 +3088,12 @@ if(_1.EField) {
|
|
|
3065
3088
|
const f_ = _1;
|
|
3066
3089
|
const recordType_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, f_.at_);
|
|
3067
3090
|
if(ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, term_.at_)) {
|
|
3068
|
-
|
|
3069
|
-
const
|
|
3091
|
+
{
|
|
3092
|
+
const if_o = hookRecordTypeBox_
|
|
3093
|
+
if(if_o.Some) {
|
|
3094
|
+
const _w1 = if_o.value_;
|
|
3070
3095
|
_w1.value_ = ff_core_Option.Some(recordType_)
|
|
3071
|
-
|
|
3096
|
+
}
|
|
3072
3097
|
}
|
|
3073
3098
|
};
|
|
3074
3099
|
const record_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, recordType_, f_.record_);
|
|
@@ -3098,7 +3123,7 @@ if(_1.Some) {
|
|
|
3098
3123
|
const instantiated_ = _1.value_;
|
|
3099
3124
|
return ff_compiler_Inference.Inference_inferLambdaCall(self_, environment_, expected_, e2_)
|
|
3100
3125
|
}
|
|
3101
|
-
|
|
3126
|
+
{
|
|
3102
3127
|
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)})
|
|
3103
3128
|
}
|
|
3104
3129
|
}
|
|
@@ -3107,7 +3132,7 @@ return
|
|
|
3107
3132
|
if(_1.TVariable && ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
|
|
3108
3133
|
return ff_compiler_Inference.Inference_inferLambdaCall(self_, environment_, expected_, e2_)
|
|
3109
3134
|
}
|
|
3110
|
-
|
|
3135
|
+
{
|
|
3111
3136
|
const index_ = _1.index_;
|
|
3112
3137
|
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)})
|
|
3113
3138
|
}
|
|
@@ -3193,7 +3218,7 @@ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Sy
|
|
|
3193
3218
|
}))
|
|
3194
3219
|
return
|
|
3195
3220
|
}
|
|
3196
|
-
|
|
3221
|
+
{
|
|
3197
3222
|
const e_ = _1;
|
|
3198
3223
|
const recordType_ = ff_compiler_Unification.Unification_freshUnificationVariable(self_.unification_, e_.at_);
|
|
3199
3224
|
const record_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, recordType_, e_.record_);
|
|
@@ -3232,7 +3257,7 @@ if(_1.Some) {
|
|
|
3232
3257
|
const instantiated_ = _1.value_;
|
|
3233
3258
|
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)})
|
|
3234
3259
|
}
|
|
3235
|
-
|
|
3260
|
+
{
|
|
3236
3261
|
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)})
|
|
3237
3262
|
}
|
|
3238
3263
|
}
|
|
@@ -3241,7 +3266,7 @@ return
|
|
|
3241
3266
|
if(_1.TVariable && ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
|
|
3242
3267
|
return term_
|
|
3243
3268
|
}
|
|
3244
|
-
|
|
3269
|
+
{
|
|
3245
3270
|
const index_ = _1.index_;
|
|
3246
3271
|
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)})
|
|
3247
3272
|
}
|
|
@@ -3253,12 +3278,24 @@ return
|
|
|
3253
3278
|
|
|
3254
3279
|
export async function Inference_inferAssignment$(self_, environment_, expected_, at_, operator_, value_, signature_, $task) {
|
|
3255
3280
|
const t_ = signature_.returnType_;
|
|
3256
|
-
|
|
3281
|
+
const newValue_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, t_, value_);
|
|
3282
|
+
if(((((operator_ === "+") || (operator_ === "-")) || (operator_ === "*")) || (operator_ === "/"))) {
|
|
3283
|
+
do {
|
|
3284
|
+
const _1 = ff_compiler_Unification.Unification_substitute(self_.unification_, t_);
|
|
3285
|
+
if(_1.TConstructor) {
|
|
3286
|
+
const name_ = _1.name_;
|
|
3287
|
+
if(((((name_ === ff_compiler_Inference.core_("Int")) || (name_ === ff_compiler_Inference.core_("Float"))) || (name_ === ff_compiler_Inference.core_("JsValue"))) || ((name_ === ff_compiler_Inference.core_("String")) && (operator_ === "+")))) {
|
|
3288
|
+
|
|
3289
|
+
break
|
|
3290
|
+
}
|
|
3291
|
+
}
|
|
3292
|
+
{
|
|
3257
3293
|
ff_compiler_Unification.Unification_unify(self_.unification_, at_, t_, ff_compiler_Syntax.TConstructor(at_, ff_compiler_Inference.core_("Int"), []))
|
|
3294
|
+
}
|
|
3295
|
+
} while(false)
|
|
3258
3296
|
} else if((operator_ !== "")) {
|
|
3259
|
-
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, (("Only +=,
|
|
3297
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, (("Only +=, -=, *=, /= and = assignments are supported. Got: " + operator_) + "=")), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
3260
3298
|
} else {};
|
|
3261
|
-
const newValue_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, t_, value_);
|
|
3262
3299
|
ff_compiler_Unification.Unification_unify(self_.unification_, at_, expected_, ff_compiler_Syntax.TConstructor(at_, ff_compiler_Inference.core_("Unit"), []));
|
|
3263
3300
|
return newValue_
|
|
3264
3301
|
}
|
|
@@ -3273,7 +3310,7 @@ if(_1.DynamicCall) {
|
|
|
3273
3310
|
const call_ = _1;
|
|
3274
3311
|
return call_.tailCall_
|
|
3275
3312
|
}
|
|
3276
|
-
|
|
3313
|
+
{
|
|
3277
3314
|
return ff_compiler_Inference.fail_(e_.at_, "Internal error: Static calls not expected in inferMethodCall")
|
|
3278
3315
|
}
|
|
3279
3316
|
}))(e_.target_);
|
|
@@ -3306,23 +3343,41 @@ export async function Inference_inferFunctionCall$(self_, environment_, expected
|
|
|
3306
3343
|
const _1 = term_;
|
|
3307
3344
|
if(_1.ECall) {
|
|
3308
3345
|
const e_ = _1;
|
|
3346
|
+
let isUnsafeJsAwaitCall_ = false;
|
|
3309
3347
|
const tailCall_ = (((_1) => {
|
|
3310
3348
|
if(_1.DynamicCall) {
|
|
3311
3349
|
const call_ = _1;
|
|
3350
|
+
do {
|
|
3351
|
+
const _1 = call_.function_;
|
|
3352
|
+
if(_1.EVariable && _1.name_ === "ff:core/Js.await") {
|
|
3353
|
+
isUnsafeJsAwaitCall_ = true
|
|
3354
|
+
break
|
|
3355
|
+
}
|
|
3356
|
+
if(_1.EVariable && _1.name_ === "ff:core/Js.awaitCancellablePromise") {
|
|
3357
|
+
isUnsafeJsAwaitCall_ = true
|
|
3358
|
+
break
|
|
3359
|
+
}
|
|
3360
|
+
{
|
|
3361
|
+
|
|
3362
|
+
}
|
|
3363
|
+
} while(false);
|
|
3312
3364
|
return call_.tailCall_
|
|
3313
3365
|
}
|
|
3314
|
-
|
|
3366
|
+
{
|
|
3315
3367
|
return ff_compiler_Inference.fail_(e_.at_, "Internal error: Static calls not expected in inferFunctionCall")
|
|
3316
3368
|
}
|
|
3317
3369
|
}))(e_.target_);
|
|
3318
3370
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, signature_.returnType_);
|
|
3319
3371
|
const arguments_ = ff_compiler_Inference.Inference_inferArguments(self_, e_.at_, name_, environment_, signature_.parameters_, e_.arguments_);
|
|
3320
|
-
|
|
3372
|
+
const effect_ = (isUnsafeJsAwaitCall_
|
|
3373
|
+
? ff_compiler_Syntax.TConstructor(term_.at_, "Q$", [])
|
|
3374
|
+
: signature_.effect_);
|
|
3375
|
+
ff_compiler_Unification.Unification_affect(self_.unification_, term_.at_, effect_, environment_.effect_);
|
|
3321
3376
|
{
|
|
3322
3377
|
const _1 = e_;
|
|
3323
3378
|
{
|
|
3324
3379
|
const _c = _1;
|
|
3325
|
-
return ff_compiler_Syntax.ECall(_c.at_, ff_compiler_Syntax.StaticCall(name_, tailCall_, instanceCall_),
|
|
3380
|
+
return ff_compiler_Syntax.ECall(_c.at_, ff_compiler_Syntax.StaticCall(name_, tailCall_, instanceCall_), effect_, ff_core_List.List_map(instantiation_, ((_w1) => {
|
|
3326
3381
|
return _w1.second_
|
|
3327
3382
|
})), arguments_, _c.dictionaries_)
|
|
3328
3383
|
return
|
|
@@ -3355,7 +3410,7 @@ return
|
|
|
3355
3410
|
if(_1.DynamicCall) {
|
|
3356
3411
|
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)})
|
|
3357
3412
|
}
|
|
3358
|
-
|
|
3413
|
+
{
|
|
3359
3414
|
return ff_compiler_Inference.fail_(e_.at_, "Internal error: Static calls not expected in inferLambdaCall")
|
|
3360
3415
|
}
|
|
3361
3416
|
}))(e_.target_);
|
|
@@ -3369,10 +3424,12 @@ const arguments_ = ff_core_List.List_map(ff_core_List.List_zip(e_.arguments_, ar
|
|
|
3369
3424
|
{
|
|
3370
3425
|
const argument_ = _1.first_;
|
|
3371
3426
|
const t_ = _1.second_;
|
|
3372
|
-
|
|
3373
|
-
const
|
|
3427
|
+
{
|
|
3428
|
+
const if_o = argument_.name_
|
|
3429
|
+
if(if_o.Some) {
|
|
3430
|
+
const name_ = if_o.value_;
|
|
3374
3431
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(argument_.at_, ("Named argument not allowed here: " + name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
3375
|
-
|
|
3432
|
+
}
|
|
3376
3433
|
};
|
|
3377
3434
|
{
|
|
3378
3435
|
const _1 = argument_;
|
|
@@ -3384,10 +3441,12 @@ return ff_compiler_Syntax.Argument(_c.at_, _c.name_, ff_compiler_Inference.Infer
|
|
|
3384
3441
|
return
|
|
3385
3442
|
}
|
|
3386
3443
|
}));
|
|
3387
|
-
|
|
3388
|
-
const
|
|
3444
|
+
{
|
|
3445
|
+
const if_o = ff_core_List.List_first(e_.typeArguments_)
|
|
3446
|
+
if(if_o.Some) {
|
|
3447
|
+
const typeArgument_ = if_o.value_;
|
|
3389
3448
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(typeArgument_.at_, "Type arguments not allowed here"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
3390
|
-
|
|
3449
|
+
}
|
|
3391
3450
|
};
|
|
3392
3451
|
ff_compiler_Unification.Unification_affect(self_.unification_, term_.at_, effect_, environment_.effect_);
|
|
3393
3452
|
{
|
|
@@ -3585,6 +3644,12 @@ const magic_ = ((t_) => {
|
|
|
3585
3644
|
const _1 = ff_compiler_Unification.Unification_substitute(self_.unification_, t_);
|
|
3586
3645
|
if(_1.TConstructor && _1.generics_.length === 0) {
|
|
3587
3646
|
const name_ = _1.name_;
|
|
3647
|
+
if((name_ === ff_compiler_Inference.core_("JsValue"))) {
|
|
3648
|
+
return ff_core_Option.Some("JsValue")
|
|
3649
|
+
}
|
|
3650
|
+
}
|
|
3651
|
+
if(_1.TConstructor && _1.generics_.length === 0) {
|
|
3652
|
+
const name_ = _1.name_;
|
|
3588
3653
|
if((name_ === ff_compiler_Inference.core_("Float"))) {
|
|
3589
3654
|
return ff_core_Option.Some("Float")
|
|
3590
3655
|
}
|
|
@@ -3607,6 +3672,16 @@ return ff_core_Option.None()
|
|
|
3607
3672
|
}
|
|
3608
3673
|
});
|
|
3609
3674
|
const chooseType_ = ((_1, _2) => {
|
|
3675
|
+
if(_1.Some && _1.value_ === "JsValue") {
|
|
3676
|
+
ff_compiler_Unification.Unification_unify(self_.unification_, e2_.at_, t1_, t2_);
|
|
3677
|
+
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t1_)
|
|
3678
|
+
return
|
|
3679
|
+
}
|
|
3680
|
+
if(_2.Some && _2.value_ === "JsValue") {
|
|
3681
|
+
ff_compiler_Unification.Unification_unify(self_.unification_, e1_.at_, t2_, t1_);
|
|
3682
|
+
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t2_)
|
|
3683
|
+
return
|
|
3684
|
+
}
|
|
3610
3685
|
if(_1.Some && _1.value_ === "String" && _2.Some) {
|
|
3611
3686
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t1_)
|
|
3612
3687
|
return
|
|
@@ -3632,12 +3707,12 @@ ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_,
|
|
|
3632
3707
|
return
|
|
3633
3708
|
}
|
|
3634
3709
|
if(_1.Some && _2.None) {
|
|
3635
|
-
ff_compiler_Unification.Unification_unify(self_.unification_,
|
|
3710
|
+
ff_compiler_Unification.Unification_unify(self_.unification_, e2_.at_, t1_, t2_);
|
|
3636
3711
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t1_)
|
|
3637
3712
|
return
|
|
3638
3713
|
}
|
|
3639
3714
|
if(_1.None && _2.Some) {
|
|
3640
|
-
ff_compiler_Unification.Unification_unify(self_.unification_,
|
|
3715
|
+
ff_compiler_Unification.Unification_unify(self_.unification_, e1_.at_, t2_, t1_);
|
|
3641
3716
|
ff_compiler_Unification.Unification_unify(self_.unification_, e_.at_, expected_, t2_)
|
|
3642
3717
|
return
|
|
3643
3718
|
}
|
|
@@ -3648,7 +3723,7 @@ return
|
|
|
3648
3723
|
if(_1.Some && _2.Some) {
|
|
3649
3724
|
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)})
|
|
3650
3725
|
}
|
|
3651
|
-
|
|
3726
|
+
{
|
|
3652
3727
|
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)})
|
|
3653
3728
|
}
|
|
3654
3729
|
});
|
|
@@ -3704,10 +3779,9 @@ return ff_compiler_Environment.Environment(_c.modulePrefix_, _c.symbols_, _c.tra
|
|
|
3704
3779
|
|
|
3705
3780
|
export async function Inference_inferArguments$(self_, callAt_, callName_, environment_, parameters_, arguments_, $task) {
|
|
3706
3781
|
if(ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) {
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
const
|
|
3710
|
-
const a_ = _1.second_;
|
|
3782
|
+
for(let for_a = arguments_, for_i = 0, for_l = for_a.length; for_i < for_l; for_i++) {
|
|
3783
|
+
const i_ = for_i;
|
|
3784
|
+
const a_ = for_a[for_i];
|
|
3711
3785
|
const p_ = ff_core_List.List_find(parameters_, ((p_) => {
|
|
3712
3786
|
return ff_core_Option.Option_any(a_.name_, ((_w1) => {
|
|
3713
3787
|
return (_w1 === p_.name_)
|
|
@@ -3718,9 +3792,7 @@ return ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, _w1.at_)
|
|
|
3718
3792
|
})))) {
|
|
3719
3793
|
ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.InferArgumentHook(self_.unification_, environment_, false, callAt_, callName_, parameters_, arguments_, i_))
|
|
3720
3794
|
}
|
|
3721
|
-
return
|
|
3722
3795
|
}
|
|
3723
|
-
}))
|
|
3724
3796
|
};
|
|
3725
3797
|
let remainingArguments_ = ff_core_List.List_toArray(arguments_);
|
|
3726
3798
|
ff_core_Array.Array_reverse(remainingArguments_);
|
|
@@ -3751,12 +3823,14 @@ return ff_core_Option.Option_contains(_w1.name_, p_.name_, ff_core_Equal.ff_core
|
|
|
3751
3823
|
{
|
|
3752
3824
|
const at_ = _1.at_;
|
|
3753
3825
|
const e_ = _1.value_;
|
|
3754
|
-
|
|
3826
|
+
{
|
|
3827
|
+
const if_o = ff_core_Array.Array_indexWhere(remainingArguments_, ((_w1) => {
|
|
3755
3828
|
return ff_core_Option.Option_contains(_w1.name_, p_.name_, ff_core_Equal.ff_core_Equal_Equal$ff_core_String_String)
|
|
3756
|
-
}))
|
|
3757
|
-
|
|
3829
|
+
}))
|
|
3830
|
+
if(if_o.Some) {
|
|
3831
|
+
const _w1 = if_o.value_;
|
|
3758
3832
|
ff_core_Array.Array_delete(remainingArguments_, _w1, 1)
|
|
3759
|
-
|
|
3833
|
+
}
|
|
3760
3834
|
};
|
|
3761
3835
|
const e2_ = ff_compiler_Inference.Inference_inferTerm(self_, environment_, t_, e_);
|
|
3762
3836
|
return ff_compiler_Syntax.Argument(at_, ff_core_Option.Some(p_.name_), e2_)
|
|
@@ -3773,7 +3847,7 @@ const callAt_ = _1.at_;
|
|
|
3773
3847
|
ff_compiler_Inference.fail_(callAt_, "Too many arguments")
|
|
3774
3848
|
return
|
|
3775
3849
|
}
|
|
3776
|
-
|
|
3850
|
+
{
|
|
3777
3851
|
const callAt_ = _1.at_;
|
|
3778
3852
|
const n_ = _1.name_.value_;
|
|
3779
3853
|
ff_compiler_Inference.fail_(callAt_, ("Unknown argument: " + n_))
|
|
@@ -3855,7 +3929,7 @@ return ff_compiler_Syntax.Parameter(_c.at_, _c.mutable_, _c.name_, ff_compiler_U
|
|
|
3855
3929
|
}));
|
|
3856
3930
|
const returnType_ = ff_compiler_Unification.Unification_instantiate(self_.unification_, instantiationMap_, scheme_.signature_.returnType_);
|
|
3857
3931
|
const effect_ = ff_compiler_Unification.Unification_instantiate(self_.unification_, instantiationMap_, scheme_.signature_.effect_);
|
|
3858
|
-
for(let
|
|
3932
|
+
for(let for_a = scheme_.signature_.constraints_, for_i = 0, for_l = for_a.length; for_i < for_l; for_i++) {
|
|
3859
3933
|
const c_ = for_a[for_i];
|
|
3860
3934
|
const generics_ = ff_core_List.List_map(c_.generics_, ((_w1) => {
|
|
3861
3935
|
return ff_compiler_Unification.Unification_instantiate(self_.unification_, instantiationMap_, _w1)
|