firefly-compiler 0.5.44 → 0.5.45

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/bin/firefly.mjs CHANGED
@@ -1,2 +1,2 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
  import * as firefly from '../output/js/ff/compiler/Main.mjs';
@@ -32,11 +32,21 @@ extend self: Inference {
32
32
  let environment = Environment.new(module, otherModules, alreadyFlat = False)
33
33
 
34
34
  let errors = Array.new()
35
- let traits = catchManyInto(errors, module.traits) {self.inferTraitDefinition(environment, _)}
36
- let instances = catchManyInto(errors, module.instances) {self.inferInstanceDefinition(environment, _)}
37
- let lets = catchManyInto(errors, module.lets) {self.inferLetDefinition(environment, _)}
38
- let functions = catchManyInto(errors, module.functions) {self.inferFunctionDefinition(environment, _)}
39
- let extends = catchManyInto(errors, module.extends) {self.inferExtendDefinition(environment, _)}
35
+ let traits = Syntax.catchManyInto(errors, module.traits) {
36
+ self.inferTraitDefinition(environment, _)
37
+ }
38
+ let instances = Syntax.catchManyInto(errors, module.instances) {
39
+ self.inferInstanceDefinition(environment, _)
40
+ }
41
+ let lets = Syntax.catchManyInto(errors, module.lets) {
42
+ self.inferLetDefinition(environment, _)
43
+ }
44
+ let functions = Syntax.catchManyInto(errors, module.functions) {
45
+ self.inferFunctionDefinition(environment, _)
46
+ }
47
+ let extends = Syntax.catchManyInto(errors, module.extends) {
48
+ self.inferExtendDefinition(environment, _)
49
+ }
40
50
  errors.drain().{
41
51
  | [] =>
42
52
  | [Pair(_, error)] => error.rethrow()
@@ -96,7 +106,7 @@ extend self: Inference {
96
106
  }
97
107
 
98
108
  definition.DInstance(
99
- methods = catchMany(definition.methods) {instanceFunction =>
109
+ methods = Syntax.catchMany(definition.methods) {instanceFunction =>
100
110
  let methodName = instanceFunction.signature.name
101
111
  let traitMethodName = traitName.reverse().dropWhile {_ != '.'}.reverse() + methodName
102
112
  let traitMethodScheme = environment.symbols.get(traitMethodName).else {
@@ -150,7 +160,7 @@ extend self: Inference {
150
160
  valueType = definition.type
151
161
  default = None
152
162
  )
153
- let functions = catchMany(definition.methods) {method =>
163
+ let functions = Syntax.catchMany(definition.methods) {method =>
154
164
  let signature = method.signature.Signature(
155
165
  generics = [...definition.generics, ...method.signature.generics]
156
166
  constraints = [...definition.constraints, ...method.signature.constraints]
@@ -1223,30 +1233,3 @@ constraintsToInstances(constraints: List[Constraint]): Map[InstanceKey, Instance
1223
1233
  )
1224
1234
  }.toMap()
1225
1235
  }
1226
-
1227
- catchMany[T](list: List[T], body: T => T): List[T] {
1228
- let errors = Array.new()
1229
- let result = catchManyInto(errors, list, body)
1230
- errors.drain().{
1231
- | [] => result
1232
- | [Pair(_, error)] => error.rethrow()
1233
- | allErrors => throw(CompileErrors(allErrors.map {_.first}))
1234
- }
1235
- }
1236
-
1237
- catchManyInto[T](errors: Array[Pair[CompileError, Error]], list: List[T], body: T => T): List[T] {
1238
- let result = list.map {x =>
1239
- try {
1240
- body(x)
1241
- } tryCatch {| CompileError(at, message), error =>
1242
- errors.push(Pair(CompileError(at, message), error))
1243
- x
1244
- } catch {| CompileErrors(compileErrors), error =>
1245
- compileErrors.each {compileError =>
1246
- errors.push(Pair(compileError, error))
1247
- }
1248
- x
1249
- }
1250
- }
1251
- if(errors.isEmpty()) {result} else {[]}
1252
- }
@@ -58,16 +58,27 @@ extend self: Resolver {
58
58
  module.file.replace("\\", "/").reverse().takeWhile {_ != '/'}.reverse().takeWhile {_ != '.'}
59
59
  let self2 = self.processImports(module.imports, otherModules)
60
60
  let self3 = self2.processDefinitions(module, None)
61
+
62
+ let errors = Array.new()
61
63
  let module2 = module.Module(
62
- types = checkDuplicates(module.types.map {self3.resolveTypeDefinition(_)}) {_.name} {_.at}
63
- traits = checkDuplicates(module.traits.map {self3.resolveTraitDefinition(_)}) {_.name} {_.at}
64
- instances = module.instances.map {self3.resolveInstanceDefinition(_)}
65
- extends = module.extends.map {self3.resolveExtendDefinition(_)}
66
- lets = checkDuplicates(module.lets.map {self3.resolveLetDefinition(_, True)}) {_.name} {_.at}
67
- functions = checkDuplicates(
68
- module.functions.map {self3.resolveFunctionDefinition(_, True, False)}
69
- ) {_.signature.name} {_.at}
64
+ types = Syntax.catchManyInto(errors, module.types) {self3.resolveTypeDefinition(_)}
65
+ traits = Syntax.catchManyInto(errors, module.traits) {self3.resolveTraitDefinition(_)}
66
+ instances = Syntax.catchManyInto(errors, module.instances) {self3.resolveInstanceDefinition(_)}
67
+ extends = Syntax.catchManyInto(errors, module.extends) {self3.resolveExtendDefinition(_)}
68
+ lets = Syntax.catchManyInto(errors, module.lets) {self3.resolveLetDefinition(_, True)}
69
+ functions = Syntax.catchManyInto(errors, module.functions) {
70
+ self3.resolveFunctionDefinition(_, True, False)
71
+ }
70
72
  )
73
+ errors.drain().{
74
+ | [] =>
75
+ | [Pair(_, error)] => error.rethrow()
76
+ | allErrors => throw(CompileErrors(allErrors.map {_.first}))
77
+ }
78
+ checkDuplicates(module2.types) {_.name} {_.at}
79
+ checkDuplicates(module2.traits) {_.name} {_.at}
80
+ checkDuplicates(module2.lets) {_.name} {_.at}
81
+ checkDuplicates(module2.functions) {_.signature.name} {_.at}
71
82
  let groupedExtendMethods = module2.extends.map {x =>
72
83
  Pair(x.type.show([]).takeWhile {_.isAsciiLetterOrDigit()}, x.methods)
73
84
  }.group()
@@ -283,3 +283,30 @@ extend self: Type {
283
283
  go(self)
284
284
  }
285
285
  }
286
+
287
+ catchMany[T](list: List[T], body: T => T): List[T] {
288
+ let errors = Array.new()
289
+ let result = catchManyInto(errors, list, body)
290
+ errors.drain().{
291
+ | [] => result
292
+ | [Pair(_, error)] => error.rethrow()
293
+ | allErrors => throw(CompileErrors(allErrors.map {_.first}))
294
+ }
295
+ }
296
+
297
+ catchManyInto[T](errors: Array[Pair[CompileError, Error]], list: List[T], body: T => T): List[T] {
298
+ let result = list.map {x =>
299
+ try {
300
+ body(x)
301
+ } tryCatch {| CompileError(at, message), error =>
302
+ errors.push(Pair(CompileError(at, message), error))
303
+ x
304
+ } catch {| CompileErrors(compileErrors), error =>
305
+ compileErrors.each {compileError =>
306
+ errors.push(Pair(compileError, error))
307
+ }
308
+ x
309
+ }
310
+ }
311
+ if(errors.isEmpty()) {result} else {[]}
312
+ }
@@ -142,59 +142,6 @@ return ff_core_Pair.Pair(ff_compiler_Unification.InstanceKey(c_.name_, typeName_
142
142
  })), ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey)
143
143
  }
144
144
 
145
- export function catchMany_(list_, body_) {
146
- const errors_ = ff_core_Array.new_();
147
- const result_ = ff_compiler_Inference.catchManyInto_(errors_, list_, body_);
148
- {
149
- const _1 = ff_core_Array.Array_drain(errors_);
150
- if(_1.length === 0) {
151
- return result_
152
- }
153
- if(_1.length === 1) {
154
- const error_ = _1[0].second_;
155
- return ff_core_Error.Error_rethrow(error_)
156
- }
157
- {
158
- const allErrors_ = _1;
159
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileErrors(ff_core_List.List_map(allErrors_, ((_w1) => {
160
- return _w1.first_
161
- }))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)})
162
- return
163
- }
164
- }
165
- }
166
-
167
- export function catchManyInto_(errors_, list_, body_) {
168
- const result_ = ff_core_List.List_map(list_, ((x_) => {
169
- return ff_core_Try.Try_catch(ff_core_Try.Try_tryCatch(ff_core_Core.try_((() => {
170
- return body_(x_)
171
- })), ((_1, _2) => {
172
- {
173
- const at_ = _1.at_;
174
- const message_ = _1.message_;
175
- const error_ = _2;
176
- errors_.array.push(ff_core_Pair.Pair(ff_compiler_Syntax.CompileError(at_, message_), error_));
177
- return x_
178
- }
179
- }), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError), ((_1, _2) => {
180
- {
181
- const compileErrors_ = _1.errors_;
182
- const error_ = _2;
183
- for(let for_a = compileErrors_, for_i = 0, for_l = for_a.length; for_i < for_l; for_i++) {
184
- const compileError_ = for_a[for_i];
185
- errors_.array.push(ff_core_Pair.Pair(compileError_, error_))
186
- };
187
- return x_
188
- }
189
- }), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)
190
- }));
191
- if(ff_core_Array.Array_isEmpty(errors_)) {
192
- return result_
193
- } else {
194
- return []
195
- }
196
- }
197
-
198
145
  export async function new_$(modules_, lspHook_, $task) {
199
146
  return ff_compiler_Inference.Inference(ff_compiler_Unification.new_(modules_, ff_compiler_LspHook.LspHook_isEnabled(lspHook_)), ff_core_StringMap.new_(), lspHook_)
200
147
  }
@@ -224,75 +171,22 @@ return ff_core_Pair.Pair(ff_compiler_Unification.InstanceKey(c_.name_, typeName_
224
171
  })), ff_compiler_Unification.ff_core_Ordering_Order$ff_compiler_Unification_InstanceKey)
225
172
  }
226
173
 
227
- export async function catchMany_$(list_, body_, $task) {
228
- const errors_ = ff_core_Array.new_();
229
- const result_ = (await ff_compiler_Inference.catchManyInto_$(errors_, list_, body_, $task));
230
- {
231
- const _1 = ff_core_Array.Array_drain(errors_);
232
- if(_1.length === 0) {
233
- return result_
234
- }
235
- if(_1.length === 1) {
236
- const error_ = _1[0].second_;
237
- return ff_core_Error.Error_rethrow(error_)
238
- }
239
- {
240
- const allErrors_ = _1;
241
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileErrors(ff_core_List.List_map(allErrors_, ((_w1) => {
242
- return _w1.first_
243
- }))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)})
244
- return
245
- }
246
- }
247
- }
248
-
249
- export async function catchManyInto_$(errors_, list_, body_, $task) {
250
- const result_ = (await ff_core_List.List_map$(list_, (async (x_, $task) => {
251
- return ff_core_Try.Try_catch(ff_core_Try.Try_tryCatch((await ff_core_Core.try_$((async ($task) => {
252
- return (await body_(x_, $task))
253
- }), $task)), ((_1, _2) => {
254
- {
255
- const at_ = _1.at_;
256
- const message_ = _1.message_;
257
- const error_ = _2;
258
- errors_.array.push(ff_core_Pair.Pair(ff_compiler_Syntax.CompileError(at_, message_), error_));
259
- return x_
260
- }
261
- }), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError), ((_1, _2) => {
262
- {
263
- const compileErrors_ = _1.errors_;
264
- const error_ = _2;
265
- for(let for_a = compileErrors_, for_i = 0, for_l = for_a.length; for_i < for_l; for_i++) {
266
- const compileError_ = for_a[for_i];
267
- errors_.array.push(ff_core_Pair.Pair(compileError_, error_))
268
- };
269
- return x_
270
- }
271
- }), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)
272
- }), $task));
273
- if(ff_core_Array.Array_isEmpty(errors_)) {
274
- return result_
275
- } else {
276
- return []
277
- }
278
- }
279
-
280
174
  export function Inference_inferModule(self_, module_, otherModules_) {
281
175
  const environment_ = ff_compiler_Environment.new_(module_, otherModules_, false);
282
176
  const errors_ = ff_core_Array.new_();
283
- const traits_ = ff_compiler_Inference.catchManyInto_(errors_, module_.traits_, ((_w1) => {
177
+ const traits_ = ff_compiler_Syntax.catchManyInto_(errors_, module_.traits_, ((_w1) => {
284
178
  return ff_compiler_Inference.Inference_inferTraitDefinition(self_, environment_, _w1)
285
179
  }));
286
- const instances_ = ff_compiler_Inference.catchManyInto_(errors_, module_.instances_, ((_w1) => {
180
+ const instances_ = ff_compiler_Syntax.catchManyInto_(errors_, module_.instances_, ((_w1) => {
287
181
  return ff_compiler_Inference.Inference_inferInstanceDefinition(self_, environment_, _w1)
288
182
  }));
289
- const lets_ = ff_compiler_Inference.catchManyInto_(errors_, module_.lets_, ((_w1) => {
183
+ const lets_ = ff_compiler_Syntax.catchManyInto_(errors_, module_.lets_, ((_w1) => {
290
184
  return ff_compiler_Inference.Inference_inferLetDefinition(self_, environment_, _w1)
291
185
  }));
292
- const functions_ = ff_compiler_Inference.catchManyInto_(errors_, module_.functions_, ((_w1) => {
186
+ const functions_ = ff_compiler_Syntax.catchManyInto_(errors_, module_.functions_, ((_w1) => {
293
187
  return ff_compiler_Inference.Inference_inferFunctionDefinition(self_, environment_, _w1)
294
188
  }));
295
- const extends_ = ff_compiler_Inference.catchManyInto_(errors_, module_.extends_, ((_w1) => {
189
+ const extends_ = ff_compiler_Syntax.catchManyInto_(errors_, module_.extends_, ((_w1) => {
296
190
  return ff_compiler_Inference.Inference_inferExtendDefinition(self_, environment_, _w1)
297
191
  }));
298
192
  do {
@@ -361,7 +255,7 @@ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Sy
361
255
  const _1 = definition_;
362
256
  {
363
257
  const _c = _1;
364
- return ff_compiler_Syntax.DInstance(_c.at_, _c.generics_, _c.constraints_, _c.traitName_, _c.typeArguments_, _c.generatorArguments_, ff_compiler_Inference.catchMany_(definition_.methods_, ((instanceFunction_) => {
258
+ return ff_compiler_Syntax.DInstance(_c.at_, _c.generics_, _c.constraints_, _c.traitName_, _c.typeArguments_, _c.generatorArguments_, ff_compiler_Syntax.catchMany_(definition_.methods_, ((instanceFunction_) => {
365
259
  const methodName_ = instanceFunction_.signature_.name_;
366
260
  const traitMethodName_ = (ff_core_String.String_reverse(ff_core_String.String_dropWhile(ff_core_String.String_reverse(traitName_), ((_w1) => {
367
261
  return (_w1 !== 46)
@@ -420,7 +314,7 @@ return ff_compiler_Syntax.DLet(_c.at_, _c.name_, _c.variableType_, value_)
420
314
 
421
315
  export function Inference_inferExtendDefinition(self_, environment_, definition_) {
422
316
  const selfParameter_ = ff_compiler_Syntax.Parameter(definition_.at_, false, definition_.name_, definition_.type_, ff_core_Option.None());
423
- const functions_ = ff_compiler_Inference.catchMany_(definition_.methods_, ((method_) => {
317
+ const functions_ = ff_compiler_Syntax.catchMany_(definition_.methods_, ((method_) => {
424
318
  const signature_ = (((_c) => {
425
319
  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_)
426
320
  }))(method_.signature_);
@@ -2197,19 +2091,19 @@ return instantiated_
2197
2091
  export async function Inference_inferModule$(self_, module_, otherModules_, $task) {
2198
2092
  const environment_ = ff_compiler_Environment.new_(module_, otherModules_, false);
2199
2093
  const errors_ = ff_core_Array.new_();
2200
- const traits_ = ff_compiler_Inference.catchManyInto_(errors_, module_.traits_, ((_w1) => {
2094
+ const traits_ = ff_compiler_Syntax.catchManyInto_(errors_, module_.traits_, ((_w1) => {
2201
2095
  return ff_compiler_Inference.Inference_inferTraitDefinition(self_, environment_, _w1)
2202
2096
  }));
2203
- const instances_ = ff_compiler_Inference.catchManyInto_(errors_, module_.instances_, ((_w1) => {
2097
+ const instances_ = ff_compiler_Syntax.catchManyInto_(errors_, module_.instances_, ((_w1) => {
2204
2098
  return ff_compiler_Inference.Inference_inferInstanceDefinition(self_, environment_, _w1)
2205
2099
  }));
2206
- const lets_ = ff_compiler_Inference.catchManyInto_(errors_, module_.lets_, ((_w1) => {
2100
+ const lets_ = ff_compiler_Syntax.catchManyInto_(errors_, module_.lets_, ((_w1) => {
2207
2101
  return ff_compiler_Inference.Inference_inferLetDefinition(self_, environment_, _w1)
2208
2102
  }));
2209
- const functions_ = ff_compiler_Inference.catchManyInto_(errors_, module_.functions_, ((_w1) => {
2103
+ const functions_ = ff_compiler_Syntax.catchManyInto_(errors_, module_.functions_, ((_w1) => {
2210
2104
  return ff_compiler_Inference.Inference_inferFunctionDefinition(self_, environment_, _w1)
2211
2105
  }));
2212
- const extends_ = ff_compiler_Inference.catchManyInto_(errors_, module_.extends_, ((_w1) => {
2106
+ const extends_ = ff_compiler_Syntax.catchManyInto_(errors_, module_.extends_, ((_w1) => {
2213
2107
  return ff_compiler_Inference.Inference_inferExtendDefinition(self_, environment_, _w1)
2214
2108
  }));
2215
2109
  do {
@@ -2278,7 +2172,7 @@ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Sy
2278
2172
  const _1 = definition_;
2279
2173
  {
2280
2174
  const _c = _1;
2281
- return ff_compiler_Syntax.DInstance(_c.at_, _c.generics_, _c.constraints_, _c.traitName_, _c.typeArguments_, _c.generatorArguments_, ff_compiler_Inference.catchMany_(definition_.methods_, ((instanceFunction_) => {
2175
+ return ff_compiler_Syntax.DInstance(_c.at_, _c.generics_, _c.constraints_, _c.traitName_, _c.typeArguments_, _c.generatorArguments_, ff_compiler_Syntax.catchMany_(definition_.methods_, ((instanceFunction_) => {
2282
2176
  const methodName_ = instanceFunction_.signature_.name_;
2283
2177
  const traitMethodName_ = (ff_core_String.String_reverse(ff_core_String.String_dropWhile(ff_core_String.String_reverse(traitName_), ((_w1) => {
2284
2178
  return (_w1 !== 46)
@@ -2337,7 +2231,7 @@ return ff_compiler_Syntax.DLet(_c.at_, _c.name_, _c.variableType_, value_)
2337
2231
 
2338
2232
  export async function Inference_inferExtendDefinition$(self_, environment_, definition_, $task) {
2339
2233
  const selfParameter_ = ff_compiler_Syntax.Parameter(definition_.at_, false, definition_.name_, definition_.type_, ff_core_Option.None());
2340
- const functions_ = ff_compiler_Inference.catchMany_(definition_.methods_, ((method_) => {
2234
+ const functions_ = ff_compiler_Syntax.catchMany_(definition_.methods_, ((method_) => {
2341
2235
  const signature_ = (((_c) => {
2342
2236
  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_)
2343
2237
  }))(method_.signature_);
@@ -163,37 +163,60 @@ return (_w1 !== 46)
163
163
  }));
164
164
  const self2_ = ff_compiler_Resolver.Resolver_processImports(self_, module_.imports_, otherModules_);
165
165
  const self3_ = ff_compiler_Resolver.Resolver_processDefinitions(self2_, module_, ff_core_Option.None());
166
+ const errors_ = ff_core_Array.new_();
166
167
  const module2_ = (((_c) => {
167
- return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, _c.imports_, ff_compiler_Resolver.checkDuplicates_(ff_core_List.List_map(module_.types_, ((_w1) => {
168
+ return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, _c.imports_, ff_compiler_Syntax.catchManyInto_(errors_, module_.types_, ((_w1) => {
168
169
  return ff_compiler_Resolver.Resolver_resolveTypeDefinition(self3_, _w1)
169
- })), ((_w1) => {
170
+ })), ff_compiler_Syntax.catchManyInto_(errors_, module_.traits_, ((_w1) => {
171
+ return ff_compiler_Resolver.Resolver_resolveTraitDefinition(self3_, _w1)
172
+ })), ff_compiler_Syntax.catchManyInto_(errors_, module_.instances_, ((_w1) => {
173
+ return ff_compiler_Resolver.Resolver_resolveInstanceDefinition(self3_, _w1)
174
+ })), ff_compiler_Syntax.catchManyInto_(errors_, module_.extends_, ((_w1) => {
175
+ return ff_compiler_Resolver.Resolver_resolveExtendDefinition(self3_, _w1)
176
+ })), ff_compiler_Syntax.catchManyInto_(errors_, module_.lets_, ((_w1) => {
177
+ return ff_compiler_Resolver.Resolver_resolveLetDefinition(self3_, _w1, true)
178
+ })), ff_compiler_Syntax.catchManyInto_(errors_, module_.functions_, ((_w1) => {
179
+ return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self3_, _w1, true, false)
180
+ })))
181
+ }))(module_);
182
+ do {
183
+ const _1 = ff_core_Array.Array_drain(errors_);
184
+ if(_1.length === 0) {
185
+
186
+ break
187
+ }
188
+ if(_1.length === 1) {
189
+ const error_ = _1[0].second_;
190
+ ff_core_Error.Error_rethrow(error_)
191
+ break
192
+ }
193
+ {
194
+ const allErrors_ = _1;
195
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileErrors(ff_core_List.List_map(allErrors_, ((_w1) => {
196
+ return _w1.first_
197
+ }))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)})
198
+ }
199
+ } while(false);
200
+ ff_compiler_Resolver.checkDuplicates_(module2_.types_, ((_w1) => {
170
201
  return _w1.name_
171
202
  }), ((_w1) => {
172
203
  return _w1.at_
173
- })), ff_compiler_Resolver.checkDuplicates_(ff_core_List.List_map(module_.traits_, ((_w1) => {
174
- return ff_compiler_Resolver.Resolver_resolveTraitDefinition(self3_, _w1)
175
- })), ((_w1) => {
204
+ }));
205
+ ff_compiler_Resolver.checkDuplicates_(module2_.traits_, ((_w1) => {
176
206
  return _w1.name_
177
207
  }), ((_w1) => {
178
208
  return _w1.at_
179
- })), ff_core_List.List_map(module_.instances_, ((_w1) => {
180
- return ff_compiler_Resolver.Resolver_resolveInstanceDefinition(self3_, _w1)
181
- })), ff_core_List.List_map(module_.extends_, ((_w1) => {
182
- return ff_compiler_Resolver.Resolver_resolveExtendDefinition(self3_, _w1)
183
- })), ff_compiler_Resolver.checkDuplicates_(ff_core_List.List_map(module_.lets_, ((_w1) => {
184
- return ff_compiler_Resolver.Resolver_resolveLetDefinition(self3_, _w1, true)
185
- })), ((_w1) => {
209
+ }));
210
+ ff_compiler_Resolver.checkDuplicates_(module2_.lets_, ((_w1) => {
186
211
  return _w1.name_
187
212
  }), ((_w1) => {
188
213
  return _w1.at_
189
- })), ff_compiler_Resolver.checkDuplicates_(ff_core_List.List_map(module_.functions_, ((_w1) => {
190
- return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self3_, _w1, true, false)
191
- })), ((_w1) => {
214
+ }));
215
+ ff_compiler_Resolver.checkDuplicates_(module2_.functions_, ((_w1) => {
192
216
  return _w1.signature_.name_
193
217
  }), ((_w1) => {
194
218
  return _w1.at_
195
- })))
196
- }))(module_);
219
+ }));
197
220
  const groupedExtendMethods_ = ff_core_List.List_group(ff_core_List.List_map(module2_.extends_, ((x_) => {
198
221
  return ff_core_Pair.Pair(ff_core_String.String_takeWhile(ff_compiler_Syntax.Type_show(x_.type_, []), ((_w1) => {
199
222
  return ff_core_Char.Char_isAsciiLetterOrDigit(_w1)
@@ -1141,37 +1164,60 @@ return (_w1 !== 46)
1141
1164
  }));
1142
1165
  const self2_ = ff_compiler_Resolver.Resolver_processImports(self_, module_.imports_, otherModules_);
1143
1166
  const self3_ = ff_compiler_Resolver.Resolver_processDefinitions(self2_, module_, ff_core_Option.None());
1167
+ const errors_ = ff_core_Array.new_();
1144
1168
  const module2_ = (((_c) => {
1145
- return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, _c.imports_, ff_compiler_Resolver.checkDuplicates_(ff_core_List.List_map(module_.types_, ((_w1) => {
1169
+ return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, _c.imports_, ff_compiler_Syntax.catchManyInto_(errors_, module_.types_, ((_w1) => {
1146
1170
  return ff_compiler_Resolver.Resolver_resolveTypeDefinition(self3_, _w1)
1147
- })), ((_w1) => {
1171
+ })), ff_compiler_Syntax.catchManyInto_(errors_, module_.traits_, ((_w1) => {
1172
+ return ff_compiler_Resolver.Resolver_resolveTraitDefinition(self3_, _w1)
1173
+ })), ff_compiler_Syntax.catchManyInto_(errors_, module_.instances_, ((_w1) => {
1174
+ return ff_compiler_Resolver.Resolver_resolveInstanceDefinition(self3_, _w1)
1175
+ })), ff_compiler_Syntax.catchManyInto_(errors_, module_.extends_, ((_w1) => {
1176
+ return ff_compiler_Resolver.Resolver_resolveExtendDefinition(self3_, _w1)
1177
+ })), ff_compiler_Syntax.catchManyInto_(errors_, module_.lets_, ((_w1) => {
1178
+ return ff_compiler_Resolver.Resolver_resolveLetDefinition(self3_, _w1, true)
1179
+ })), ff_compiler_Syntax.catchManyInto_(errors_, module_.functions_, ((_w1) => {
1180
+ return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self3_, _w1, true, false)
1181
+ })))
1182
+ }))(module_);
1183
+ do {
1184
+ const _1 = ff_core_Array.Array_drain(errors_);
1185
+ if(_1.length === 0) {
1186
+
1187
+ break
1188
+ }
1189
+ if(_1.length === 1) {
1190
+ const error_ = _1[0].second_;
1191
+ ff_core_Error.Error_rethrow(error_)
1192
+ break
1193
+ }
1194
+ {
1195
+ const allErrors_ = _1;
1196
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileErrors(ff_core_List.List_map(allErrors_, ((_w1) => {
1197
+ return _w1.first_
1198
+ }))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)})
1199
+ }
1200
+ } while(false);
1201
+ ff_compiler_Resolver.checkDuplicates_(module2_.types_, ((_w1) => {
1148
1202
  return _w1.name_
1149
1203
  }), ((_w1) => {
1150
1204
  return _w1.at_
1151
- })), ff_compiler_Resolver.checkDuplicates_(ff_core_List.List_map(module_.traits_, ((_w1) => {
1152
- return ff_compiler_Resolver.Resolver_resolveTraitDefinition(self3_, _w1)
1153
- })), ((_w1) => {
1205
+ }));
1206
+ ff_compiler_Resolver.checkDuplicates_(module2_.traits_, ((_w1) => {
1154
1207
  return _w1.name_
1155
1208
  }), ((_w1) => {
1156
1209
  return _w1.at_
1157
- })), ff_core_List.List_map(module_.instances_, ((_w1) => {
1158
- return ff_compiler_Resolver.Resolver_resolveInstanceDefinition(self3_, _w1)
1159
- })), ff_core_List.List_map(module_.extends_, ((_w1) => {
1160
- return ff_compiler_Resolver.Resolver_resolveExtendDefinition(self3_, _w1)
1161
- })), ff_compiler_Resolver.checkDuplicates_(ff_core_List.List_map(module_.lets_, ((_w1) => {
1162
- return ff_compiler_Resolver.Resolver_resolveLetDefinition(self3_, _w1, true)
1163
- })), ((_w1) => {
1210
+ }));
1211
+ ff_compiler_Resolver.checkDuplicates_(module2_.lets_, ((_w1) => {
1164
1212
  return _w1.name_
1165
1213
  }), ((_w1) => {
1166
1214
  return _w1.at_
1167
- })), ff_compiler_Resolver.checkDuplicates_(ff_core_List.List_map(module_.functions_, ((_w1) => {
1168
- return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self3_, _w1, true, false)
1169
- })), ((_w1) => {
1215
+ }));
1216
+ ff_compiler_Resolver.checkDuplicates_(module2_.functions_, ((_w1) => {
1170
1217
  return _w1.signature_.name_
1171
1218
  }), ((_w1) => {
1172
1219
  return _w1.at_
1173
- })))
1174
- }))(module_);
1220
+ }));
1175
1221
  const groupedExtendMethods_ = ff_core_List.List_group(ff_core_List.List_map(module2_.extends_, ((x_) => {
1176
1222
  return ff_core_Pair.Pair(ff_core_String.String_takeWhile(ff_compiler_Syntax.Type_show(x_.type_, []), ((_w1) => {
1177
1223
  return ff_core_Char.Char_isAsciiLetterOrDigit(_w1)
@@ -358,9 +358,111 @@ return {at_, major_, minor_, patch_};
358
358
 
359
359
 
360
360
 
361
+ export function catchMany_(list_, body_) {
362
+ const errors_ = ff_core_Array.new_();
363
+ const result_ = ff_compiler_Syntax.catchManyInto_(errors_, list_, body_);
364
+ {
365
+ const _1 = ff_core_Array.Array_drain(errors_);
366
+ if(_1.length === 0) {
367
+ return result_
368
+ }
369
+ if(_1.length === 1) {
370
+ const error_ = _1[0].second_;
371
+ return ff_core_Error.Error_rethrow(error_)
372
+ }
373
+ {
374
+ const allErrors_ = _1;
375
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileErrors(ff_core_List.List_map(allErrors_, ((_w1) => {
376
+ return _w1.first_
377
+ }))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)})
378
+ return
379
+ }
380
+ }
381
+ }
361
382
 
383
+ export function catchManyInto_(errors_, list_, body_) {
384
+ const result_ = ff_core_List.List_map(list_, ((x_) => {
385
+ return ff_core_Try.Try_catch(ff_core_Try.Try_tryCatch(ff_core_Core.try_((() => {
386
+ return body_(x_)
387
+ })), ((_1, _2) => {
388
+ {
389
+ const at_ = _1.at_;
390
+ const message_ = _1.message_;
391
+ const error_ = _2;
392
+ errors_.array.push(ff_core_Pair.Pair(ff_compiler_Syntax.CompileError(at_, message_), error_));
393
+ return x_
394
+ }
395
+ }), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError), ((_1, _2) => {
396
+ {
397
+ const compileErrors_ = _1.errors_;
398
+ const error_ = _2;
399
+ for(let for_a = compileErrors_, for_i = 0, for_l = for_a.length; for_i < for_l; for_i++) {
400
+ const compileError_ = for_a[for_i];
401
+ errors_.array.push(ff_core_Pair.Pair(compileError_, error_))
402
+ };
403
+ return x_
404
+ }
405
+ }), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)
406
+ }));
407
+ if(ff_core_Array.Array_isEmpty(errors_)) {
408
+ return result_
409
+ } else {
410
+ return []
411
+ }
412
+ }
362
413
 
414
+ export async function catchMany_$(list_, body_, $task) {
415
+ const errors_ = ff_core_Array.new_();
416
+ const result_ = (await ff_compiler_Syntax.catchManyInto_$(errors_, list_, body_, $task));
417
+ {
418
+ const _1 = ff_core_Array.Array_drain(errors_);
419
+ if(_1.length === 0) {
420
+ return result_
421
+ }
422
+ if(_1.length === 1) {
423
+ const error_ = _1[0].second_;
424
+ return ff_core_Error.Error_rethrow(error_)
425
+ }
426
+ {
427
+ const allErrors_ = _1;
428
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileErrors(ff_core_List.List_map(allErrors_, ((_w1) => {
429
+ return _w1.first_
430
+ }))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)})
431
+ return
432
+ }
433
+ }
434
+ }
363
435
 
436
+ export async function catchManyInto_$(errors_, list_, body_, $task) {
437
+ const result_ = (await ff_core_List.List_map$(list_, (async (x_, $task) => {
438
+ return ff_core_Try.Try_catch(ff_core_Try.Try_tryCatch((await ff_core_Core.try_$((async ($task) => {
439
+ return (await body_(x_, $task))
440
+ }), $task)), ((_1, _2) => {
441
+ {
442
+ const at_ = _1.at_;
443
+ const message_ = _1.message_;
444
+ const error_ = _2;
445
+ errors_.array.push(ff_core_Pair.Pair(ff_compiler_Syntax.CompileError(at_, message_), error_));
446
+ return x_
447
+ }
448
+ }), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError), ((_1, _2) => {
449
+ {
450
+ const compileErrors_ = _1.errors_;
451
+ const error_ = _2;
452
+ for(let for_a = compileErrors_, for_i = 0, for_l = for_a.length; for_i < for_l; for_i++) {
453
+ const compileError_ = for_a[for_i];
454
+ errors_.array.push(ff_core_Pair.Pair(compileError_, error_))
455
+ };
456
+ return x_
457
+ }
458
+ }), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)
459
+ }), $task));
460
+ if(ff_core_Array.Array_isEmpty(errors_)) {
461
+ return result_
462
+ } else {
463
+ return []
464
+ }
465
+ }
364
466
 
365
467
  export function Location_show(self_) {
366
468
  return (((((("in " + self_.file_) + " ") + "at line ") + self_.line_) + ", column ") + self_.column_)
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "description": "Firefly compiler",
5
5
  "author": "Firefly team",
6
6
  "license": "MIT",
7
- "version": "0.5.44",
7
+ "version": "0.5.45",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/Ahnfelt/firefly-boot"
@@ -4,7 +4,7 @@
4
4
  "description": "Firefly language support",
5
5
  "author": "Firefly team",
6
6
  "license": "MIT",
7
- "version": "0.5.44",
7
+ "version": "0.5.45",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/Ahnfelt/firefly-boot"