firefly-compiler 0.5.43 → 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';
@@ -167,9 +167,12 @@ extend self: Compiler {
167
167
  }
168
168
  try {
169
169
  self.parse(newPackagePair, newModuleName, Some(import.at))
170
- } catch {| CompileError(_, _) @ e, error =>
170
+ } tryCatch {| CompileError(_, _) @ e, error =>
171
171
  let newError = CompileError(import.at, "Parse error in imported module: " + import.package.groupName() + "/" + newModuleName)
172
172
  throw(CompileErrors([e, newError]))
173
+ } catch {| CompileErrors(compileErrors), error =>
174
+ let newError = CompileError(import.at, "Parse errors in imported module: " + import.package.groupName() + "/" + newModuleName)
175
+ throw(CompileErrors([...compileErrors, newError]))
173
176
  }
174
177
  }
175
178
  }
@@ -27,15 +27,32 @@ core(name: String): String {
27
27
  }
28
28
 
29
29
  extend self: Inference {
30
-
30
+
31
31
  inferModule(module: Module, otherModules: List[Module]): Module {
32
32
  let environment = Environment.new(module, otherModules, alreadyFlat = False)
33
33
 
34
- let traits = module.traits.map {self.inferTraitDefinition(environment, _)}
35
- let instances = module.instances.map {self.inferInstanceDefinition(environment, _)}
36
- let lets = module.lets.map {self.inferLetDefinition(environment, _)}
37
- let functions = module.functions.map {self.inferFunctionDefinition(environment, _)}
38
- let extends = module.extends.map {self.inferExtendDefinition(environment, _)}
34
+ let errors = Array.new()
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
+ }
50
+ errors.drain().{
51
+ | [] =>
52
+ | [Pair(_, error)] => error.rethrow()
53
+ | allErrors => throw(CompileErrors(allErrors.map {_.first}))
54
+ }
55
+
39
56
  let result = module.Module(
40
57
  traits = traits
41
58
  instances = instances
@@ -89,7 +106,7 @@ extend self: Inference {
89
106
  }
90
107
 
91
108
  definition.DInstance(
92
- methods = definition.methods.map {instanceFunction =>
109
+ methods = Syntax.catchMany(definition.methods) {instanceFunction =>
93
110
  let methodName = instanceFunction.signature.name
94
111
  let traitMethodName = traitName.reverse().dropWhile {_ != '.'}.reverse() + methodName
95
112
  let traitMethodScheme = environment.symbols.get(traitMethodName).else {
@@ -143,7 +160,7 @@ extend self: Inference {
143
160
  valueType = definition.type
144
161
  default = None
145
162
  )
146
- let functions = definition.methods.map {method =>
163
+ let functions = Syntax.catchMany(definition.methods) {method =>
147
164
  let signature = method.signature.Signature(
148
165
  generics = [...definition.generics, ...method.signature.generics]
149
166
  constraints = [...definition.constraints, ...method.signature.constraints]
@@ -824,7 +824,7 @@ extend self: Parser {
824
824
  while {self.current().rawIs("{")} {
825
825
  guards.push(self.parseCaseGuard())
826
826
  }
827
- if(!self.lspHook.isEnabled() || !self.current().is2(LPipe, LBracketRight)) {
827
+ if(!self.lspHook.isEnabled() || self.current().is(LArrowThick)) {
828
828
  self.skip(LArrowThick)
829
829
  }
830
830
  let body = self.parseStatements()
@@ -1040,7 +1040,13 @@ extend self: Parser {
1040
1040
  }
1041
1041
 
1042
1042
  parseBinary(level: Int): Term {
1043
- if(level >= binaryOperators.size()) {self.parseUnary()} else:
1043
+ if(level >= binaryOperators.size()) {
1044
+ if(self.lspHook.isEnabled() && self.current().is(LBracketRight)) {
1045
+ EVariable(self.current().at(), "")
1046
+ } else {
1047
+ self.parseUnary()
1048
+ }
1049
+ } else:
1044
1050
  let operators = binaryOperators.grab(level)
1045
1051
  mutable result = self.parseBinary(level + 1)
1046
1052
  if(self.current().is(LOperator)) {
@@ -58,18 +58,37 @@ 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 = module.types.map {self3.resolveTypeDefinition(_)}
63
- traits = module.traits.map {self3.resolveTraitDefinition(_)}
64
- instances = module.instances.map {self3.resolveInstanceDefinition(_)}
65
- extends = module.extends.map {self3.resolveExtendDefinition(_)}
66
- lets = module.lets.map {self3.resolveLetDefinition(_, True)}
67
- functions = module.functions.map {self3.resolveFunctionDefinition(_, True, False)}
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
+ }
68
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}
82
+ let groupedExtendMethods = module2.extends.map {x =>
83
+ Pair(x.type.show([]).takeWhile {_.isAsciiLetterOrDigit()}, x.methods)
84
+ }.group()
85
+ groupedExtendMethods.values().map {_.flatten()}.map {methods =>
86
+ checkDuplicates(methods) {_.signature.name} {_.at}
87
+ }
69
88
  module2.instances.each {_.typeArguments.each {self3.checkInstanceType(_)}}
70
89
  module2
71
90
  }
72
-
91
+
73
92
  checkInstanceType(type: Type) {
74
93
  type.{
75
94
  | TConstructor(_, name, typeArguments) =>
@@ -159,7 +178,7 @@ extend self: Resolver {
159
178
  }
160
179
  definition.DType(
161
180
  constraints = definition.constraints.map {self2.resolveConstraint(_, True)}
162
- commonFields = definition.commonFields.map {f =>
181
+ commonFields = checkDuplicates(definition.commonFields.map {f =>
163
182
  let valueType = self2.resolveType(f.valueType, True)
164
183
  if(self.lspHook.isAt(f.at) || self.lspHook.isDefinedAt(f.at)) {
165
184
  self.lspHook.emit(
@@ -170,13 +189,14 @@ extend self: Resolver {
170
189
  valueType = valueType
171
190
  default = f.default.map {self2.resolveTerm(_, True)}
172
191
  )
173
- }
174
- variants = definition.variants.map {v =>
192
+ }) {_.name} {_.at}
193
+ variants = checkDuplicates(definition.variants.map {v =>
175
194
  if(self.lspHook.isAt(v.at)) {
176
195
  self.lspHook.emit(
177
196
  ResolveSymbolHook(SymbolHook(v.name, v.at, v.at), None, topLevel = True)
178
197
  )
179
198
  }
199
+ checkDuplicates([...definition.commonFields, ...v.fields]) {_.name} {_.at}
180
200
  v.Variant(fields = v.fields.map {f =>
181
201
  let valueType = self2.resolveType(f.valueType, True)
182
202
  if(self.lspHook.isAt(f.at) || self.lspHook.isDefinedAt(f.at)) {
@@ -189,7 +209,7 @@ extend self: Resolver {
189
209
  default = f.default.map {self2.resolveTerm(_, True) }
190
210
  )
191
211
  })
192
- }
212
+ }) {_.name} {_.at}
193
213
  )
194
214
  }
195
215
 
@@ -209,7 +229,9 @@ extend self: Resolver {
209
229
  )
210
230
  definition.DTrait(
211
231
  constraints = definition.constraints.map {self2.resolveConstraint(_, True)}
212
- methods = definition.methods.map {self2.resolveSignature(_, True, False)}
232
+ methods = checkDuplicates(
233
+ definition.methods.map {self2.resolveSignature(_, True, False)}
234
+ ) {_.name} {_.at}
213
235
  methodDefaults = definition.methodDefaults.map {| Pair(name, lambda) =>
214
236
  let signature = definition.methods.find {_.name == name}.grab()
215
237
  let function1 = DFunction(signature.at, signature, lambda)
@@ -623,3 +645,15 @@ extend self: Resolver {
623
645
  }
624
646
 
625
647
  }
648
+
649
+ checkDuplicates[T](items: List[T], name: T => String, at: T => Location): List[T] {
650
+ mutable seen = Map.new()
651
+ items.map {item =>
652
+ let n = name(item)
653
+ if(seen.contains(n)) {
654
+ throw(CompileError(at(item), "Duplicate definition: " + n))
655
+ }
656
+ seen = seen.add(n, item)
657
+ }
658
+ items
659
+ }
@@ -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
+ }
package/lsp/Handler.ff CHANGED
@@ -279,6 +279,9 @@ extend self: Handler {
279
279
  } tryCatch {| CompileError(at, message), error =>
280
280
  Log.trace("handleDocumentSymbol parse error: " + message)
281
281
  []
282
+ } tryCatch {| CompileErrors(_), error =>
283
+ Log.trace("handleDocumentSymbol parse errors: ")
284
+ []
282
285
  } catch {| ReadSymbolsError e, _ =>
283
286
  Log.trace("handleDocumentSymbol ReadSymbolsError")
284
287
  []
@@ -402,8 +405,10 @@ extend self: Handler {
402
405
  let tokens = Tokenizer.tokenize(cursorAt.file, code, None, True)
403
406
  let parser = Parser.new(PackagePair("script", "script"), cursorAt.file, tokens, False, lspHook)
404
407
  parser.parseModuleWithPackageInfo()
405
- } catch {| CompileError(at, message), error =>
408
+ } tryCatch {| CompileError(at, message), error =>
406
409
  Log.trace("handleSignatureHelp check error: " + message)
410
+ } catch {| CompileErrors(_), error =>
411
+ Log.trace("handleSignatureHelp check errors")
407
412
  }
408
413
  let o = lspHook.results().collectFirst {
409
414
  | ParseArgumentHook h {parameters.get("context") | Some(context)} {
@@ -209,19 +209,23 @@ return (_w1 + "/")
209
209
  if((!ff_core_Map.Map_contains(self_.packagePaths_, newPackagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair))) {
210
210
  throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(import_.at_, ("Missing dependency declaration for: " + ff_compiler_Syntax.PackagePair_groupName(newPackagePair_, ":"))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
211
211
  };
212
- try {
212
+ return ff_core_Try.Try_catch(ff_core_Try.Try_tryCatch(ff_core_Core.try_((() => {
213
213
  return ff_compiler_Compiler.Compiler_parse(self_, newPackagePair_, newModuleName_, ff_core_Option.Some(import_.at_))
214
- } catch(_error) {
215
- if(!_error.ffException) throw _error
216
- const _exception = ff_core_Any.fromAny_(_error.ffException, ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)
217
- if(!_exception.Some) throw _error
214
+ })), ((_1, _2) => {
218
215
  {
219
- const e_ = _exception.value_;
220
- const error_ = _error;
216
+ const e_ = _1;
217
+ const error_ = _2;
221
218
  const newError_ = ff_compiler_Syntax.CompileError(import_.at_, ((("Parse error in imported module: " + ff_compiler_Syntax.PackagePair_groupName(import_.package_, ":")) + "/") + newModuleName_));
222
219
  throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileErrors([e_, newError_]), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)})
223
220
  }
221
+ }), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError), ((_1, _2) => {
222
+ {
223
+ const compileErrors_ = _1.errors_;
224
+ const error_ = _2;
225
+ const newError_ = ff_compiler_Syntax.CompileError(import_.at_, ((("Parse errors in imported module: " + ff_compiler_Syntax.PackagePair_groupName(import_.package_, ":")) + "/") + newModuleName_));
226
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileErrors([...compileErrors_, newError_]), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)})
224
227
  }
228
+ }), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)
225
229
  }))
226
230
  }
227
231
 
@@ -346,19 +350,23 @@ return (_w1 + "/")
346
350
  if((!ff_core_Map.Map_contains(self_.packagePaths_, newPackagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair))) {
347
351
  throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(import_.at_, ("Missing dependency declaration for: " + ff_compiler_Syntax.PackagePair_groupName(newPackagePair_, ":"))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
348
352
  };
349
- try {
353
+ return ff_core_Try.Try_catch(ff_core_Try.Try_tryCatch((await ff_core_Core.try_$((async ($task) => {
350
354
  return (await ff_compiler_Compiler.Compiler_parse$(self_, newPackagePair_, newModuleName_, ff_core_Option.Some(import_.at_), $task))
351
- } catch(_error) {
352
- if(!_error.ffException) throw _error
353
- const _exception = ff_core_Any.fromAny_(_error.ffException, ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)
354
- if(!_exception.Some) throw _error
355
+ }), $task)), ((_1, _2) => {
355
356
  {
356
- const e_ = _exception.value_;
357
- const error_ = _error;
357
+ const e_ = _1;
358
+ const error_ = _2;
358
359
  const newError_ = ff_compiler_Syntax.CompileError(import_.at_, ((("Parse error in imported module: " + ff_compiler_Syntax.PackagePair_groupName(import_.package_, ":")) + "/") + newModuleName_));
359
360
  throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileErrors([e_, newError_]), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)})
360
361
  }
362
+ }), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError), ((_1, _2) => {
363
+ {
364
+ const compileErrors_ = _1.errors_;
365
+ const error_ = _2;
366
+ const newError_ = ff_compiler_Syntax.CompileError(import_.at_, ((("Parse errors in imported module: " + ff_compiler_Syntax.PackagePair_groupName(import_.package_, ":")) + "/") + newModuleName_));
367
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileErrors([...compileErrors_, newError_]), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)})
361
368
  }
369
+ }), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)
362
370
  }), $task))
363
371
  }
364
372
 
@@ -173,21 +173,40 @@ return ff_core_Pair.Pair(ff_compiler_Unification.InstanceKey(c_.name_, typeName_
173
173
 
174
174
  export function Inference_inferModule(self_, module_, otherModules_) {
175
175
  const environment_ = ff_compiler_Environment.new_(module_, otherModules_, false);
176
- const traits_ = ff_core_List.List_map(module_.traits_, ((_w1) => {
176
+ const errors_ = ff_core_Array.new_();
177
+ const traits_ = ff_compiler_Syntax.catchManyInto_(errors_, module_.traits_, ((_w1) => {
177
178
  return ff_compiler_Inference.Inference_inferTraitDefinition(self_, environment_, _w1)
178
179
  }));
179
- const instances_ = ff_core_List.List_map(module_.instances_, ((_w1) => {
180
+ const instances_ = ff_compiler_Syntax.catchManyInto_(errors_, module_.instances_, ((_w1) => {
180
181
  return ff_compiler_Inference.Inference_inferInstanceDefinition(self_, environment_, _w1)
181
182
  }));
182
- const lets_ = ff_core_List.List_map(module_.lets_, ((_w1) => {
183
+ const lets_ = ff_compiler_Syntax.catchManyInto_(errors_, module_.lets_, ((_w1) => {
183
184
  return ff_compiler_Inference.Inference_inferLetDefinition(self_, environment_, _w1)
184
185
  }));
185
- const functions_ = ff_core_List.List_map(module_.functions_, ((_w1) => {
186
+ const functions_ = ff_compiler_Syntax.catchManyInto_(errors_, module_.functions_, ((_w1) => {
186
187
  return ff_compiler_Inference.Inference_inferFunctionDefinition(self_, environment_, _w1)
187
188
  }));
188
- const extends_ = ff_core_List.List_map(module_.extends_, ((_w1) => {
189
+ const extends_ = ff_compiler_Syntax.catchManyInto_(errors_, module_.extends_, ((_w1) => {
189
190
  return ff_compiler_Inference.Inference_inferExtendDefinition(self_, environment_, _w1)
190
191
  }));
192
+ do {
193
+ const _1 = ff_core_Array.Array_drain(errors_);
194
+ if(_1.length === 0) {
195
+
196
+ break
197
+ }
198
+ if(_1.length === 1) {
199
+ const error_ = _1[0].second_;
200
+ ff_core_Error.Error_rethrow(error_)
201
+ break
202
+ }
203
+ {
204
+ const allErrors_ = _1;
205
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileErrors(ff_core_List.List_map(allErrors_, ((_w1) => {
206
+ return _w1.first_
207
+ }))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)})
208
+ }
209
+ } while(false);
191
210
  const result_ = (((_c) => {
192
211
  return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, _c.imports_, _c.types_, traits_, instances_, extends_, lets_, functions_)
193
212
  }))(module_);
@@ -236,7 +255,7 @@ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Sy
236
255
  const _1 = definition_;
237
256
  {
238
257
  const _c = _1;
239
- return ff_compiler_Syntax.DInstance(_c.at_, _c.generics_, _c.constraints_, _c.traitName_, _c.typeArguments_, _c.generatorArguments_, ff_core_List.List_map(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_) => {
240
259
  const methodName_ = instanceFunction_.signature_.name_;
241
260
  const traitMethodName_ = (ff_core_String.String_reverse(ff_core_String.String_dropWhile(ff_core_String.String_reverse(traitName_), ((_w1) => {
242
261
  return (_w1 !== 46)
@@ -295,7 +314,7 @@ return ff_compiler_Syntax.DLet(_c.at_, _c.name_, _c.variableType_, value_)
295
314
 
296
315
  export function Inference_inferExtendDefinition(self_, environment_, definition_) {
297
316
  const selfParameter_ = ff_compiler_Syntax.Parameter(definition_.at_, false, definition_.name_, definition_.type_, ff_core_Option.None());
298
- const functions_ = ff_core_List.List_map(definition_.methods_, ((method_) => {
317
+ const functions_ = ff_compiler_Syntax.catchMany_(definition_.methods_, ((method_) => {
299
318
  const signature_ = (((_c) => {
300
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_)
301
320
  }))(method_.signature_);
@@ -2071,21 +2090,40 @@ return instantiated_
2071
2090
 
2072
2091
  export async function Inference_inferModule$(self_, module_, otherModules_, $task) {
2073
2092
  const environment_ = ff_compiler_Environment.new_(module_, otherModules_, false);
2074
- const traits_ = ff_core_List.List_map(module_.traits_, ((_w1) => {
2093
+ const errors_ = ff_core_Array.new_();
2094
+ const traits_ = ff_compiler_Syntax.catchManyInto_(errors_, module_.traits_, ((_w1) => {
2075
2095
  return ff_compiler_Inference.Inference_inferTraitDefinition(self_, environment_, _w1)
2076
2096
  }));
2077
- const instances_ = ff_core_List.List_map(module_.instances_, ((_w1) => {
2097
+ const instances_ = ff_compiler_Syntax.catchManyInto_(errors_, module_.instances_, ((_w1) => {
2078
2098
  return ff_compiler_Inference.Inference_inferInstanceDefinition(self_, environment_, _w1)
2079
2099
  }));
2080
- const lets_ = ff_core_List.List_map(module_.lets_, ((_w1) => {
2100
+ const lets_ = ff_compiler_Syntax.catchManyInto_(errors_, module_.lets_, ((_w1) => {
2081
2101
  return ff_compiler_Inference.Inference_inferLetDefinition(self_, environment_, _w1)
2082
2102
  }));
2083
- const functions_ = ff_core_List.List_map(module_.functions_, ((_w1) => {
2103
+ const functions_ = ff_compiler_Syntax.catchManyInto_(errors_, module_.functions_, ((_w1) => {
2084
2104
  return ff_compiler_Inference.Inference_inferFunctionDefinition(self_, environment_, _w1)
2085
2105
  }));
2086
- const extends_ = ff_core_List.List_map(module_.extends_, ((_w1) => {
2106
+ const extends_ = ff_compiler_Syntax.catchManyInto_(errors_, module_.extends_, ((_w1) => {
2087
2107
  return ff_compiler_Inference.Inference_inferExtendDefinition(self_, environment_, _w1)
2088
2108
  }));
2109
+ do {
2110
+ const _1 = ff_core_Array.Array_drain(errors_);
2111
+ if(_1.length === 0) {
2112
+
2113
+ break
2114
+ }
2115
+ if(_1.length === 1) {
2116
+ const error_ = _1[0].second_;
2117
+ ff_core_Error.Error_rethrow(error_)
2118
+ break
2119
+ }
2120
+ {
2121
+ const allErrors_ = _1;
2122
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileErrors(ff_core_List.List_map(allErrors_, ((_w1) => {
2123
+ return _w1.first_
2124
+ }))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)})
2125
+ }
2126
+ } while(false);
2089
2127
  const result_ = (((_c) => {
2090
2128
  return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, _c.imports_, _c.types_, traits_, instances_, extends_, lets_, functions_)
2091
2129
  }))(module_);
@@ -2134,7 +2172,7 @@ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Sy
2134
2172
  const _1 = definition_;
2135
2173
  {
2136
2174
  const _c = _1;
2137
- return ff_compiler_Syntax.DInstance(_c.at_, _c.generics_, _c.constraints_, _c.traitName_, _c.typeArguments_, _c.generatorArguments_, ff_core_List.List_map(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_) => {
2138
2176
  const methodName_ = instanceFunction_.signature_.name_;
2139
2177
  const traitMethodName_ = (ff_core_String.String_reverse(ff_core_String.String_dropWhile(ff_core_String.String_reverse(traitName_), ((_w1) => {
2140
2178
  return (_w1 !== 46)
@@ -2193,7 +2231,7 @@ return ff_compiler_Syntax.DLet(_c.at_, _c.name_, _c.variableType_, value_)
2193
2231
 
2194
2232
  export async function Inference_inferExtendDefinition$(self_, environment_, definition_, $task) {
2195
2233
  const selfParameter_ = ff_compiler_Syntax.Parameter(definition_.at_, false, definition_.name_, definition_.type_, ff_core_Option.None());
2196
- const functions_ = ff_core_List.List_map(definition_.methods_, ((method_) => {
2234
+ const functions_ = ff_compiler_Syntax.catchMany_(definition_.methods_, ((method_) => {
2197
2235
  const signature_ = (((_c) => {
2198
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_)
2199
2237
  }))(method_.signature_);
@@ -933,7 +933,7 @@ const guards_ = ff_core_Array.new_();
933
933
  while(ff_compiler_Token.Token_rawIs(ff_compiler_Parser.Parser_current(self_), "{")) {
934
934
  guards_.array.push(ff_compiler_Parser.Parser_parseCaseGuard(self_))
935
935
  };
936
- if(((!ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) || (!ff_compiler_Token.Token_is2(ff_compiler_Parser.Parser_current(self_), ff_compiler_Token.LPipe(), ff_compiler_Token.LBracketRight())))) {
936
+ if(((!ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) || ff_compiler_Token.Token_is(ff_compiler_Parser.Parser_current(self_), ff_compiler_Token.LArrowThick()))) {
937
937
  ff_compiler_Parser.Parser_skip(self_, ff_compiler_Token.LArrowThick())
938
938
  };
939
939
  const body_ = ff_compiler_Parser.Parser_parseStatements(self_);
@@ -1201,7 +1201,11 @@ return ff_compiler_Parser.Parser_parseBinary(self_, 0)
1201
1201
 
1202
1202
  export function Parser_parseBinary(self_, level_) {
1203
1203
  if((level_ >= ff_compiler_Parser.binaryOperators_.length)) {
1204
+ if((ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_) && ff_compiler_Token.Token_is(ff_compiler_Parser.Parser_current(self_), ff_compiler_Token.LBracketRight()))) {
1205
+ return ff_compiler_Syntax.EVariable(ff_compiler_Token.Token_at(ff_compiler_Parser.Parser_current(self_)), "")
1206
+ } else {
1204
1207
  return ff_compiler_Parser.Parser_parseUnary(self_)
1208
+ }
1205
1209
  } else {
1206
1210
  const operators_ = (ff_compiler_Parser.binaryOperators_[level_] ?? ff_core_List.List_grab(ff_compiler_Parser.binaryOperators_, level_));
1207
1211
  let result_ = ff_compiler_Parser.Parser_parseBinary(self_, (level_ + 1));
@@ -2433,7 +2437,7 @@ const guards_ = ff_core_Array.new_();
2433
2437
  while(ff_compiler_Token.Token_rawIs(ff_compiler_Parser.Parser_current(self_), "{")) {
2434
2438
  guards_.array.push(ff_compiler_Parser.Parser_parseCaseGuard(self_))
2435
2439
  };
2436
- if(((!ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) || (!ff_compiler_Token.Token_is2(ff_compiler_Parser.Parser_current(self_), ff_compiler_Token.LPipe(), ff_compiler_Token.LBracketRight())))) {
2440
+ if(((!ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_)) || ff_compiler_Token.Token_is(ff_compiler_Parser.Parser_current(self_), ff_compiler_Token.LArrowThick()))) {
2437
2441
  ff_compiler_Parser.Parser_skip(self_, ff_compiler_Token.LArrowThick())
2438
2442
  };
2439
2443
  const body_ = ff_compiler_Parser.Parser_parseStatements(self_);
@@ -2701,7 +2705,11 @@ return ff_compiler_Parser.Parser_parseBinary(self_, 0)
2701
2705
 
2702
2706
  export async function Parser_parseBinary$(self_, level_, $task) {
2703
2707
  if((level_ >= ff_compiler_Parser.binaryOperators_.length)) {
2708
+ if((ff_compiler_LspHook.LspHook_isEnabled(self_.lspHook_) && ff_compiler_Token.Token_is(ff_compiler_Parser.Parser_current(self_), ff_compiler_Token.LBracketRight()))) {
2709
+ return ff_compiler_Syntax.EVariable(ff_compiler_Token.Token_at(ff_compiler_Parser.Parser_current(self_)), "")
2710
+ } else {
2704
2711
  return ff_compiler_Parser.Parser_parseUnary(self_)
2712
+ }
2705
2713
  } else {
2706
2714
  const operators_ = (ff_compiler_Parser.binaryOperators_[level_] ?? ff_core_List.List_grab(ff_compiler_Parser.binaryOperators_, level_));
2707
2715
  let result_ = ff_compiler_Parser.Parser_parseBinary(self_, (level_ + 1));
@@ -121,10 +121,34 @@ export function new_(packagePair_, moduleName_, lspHook_) {
121
121
  return ff_compiler_Resolver.Resolver(ff_core_List.List_toMap([], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap([], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap([], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap([], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap([], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap([], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toSet([], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toSet([], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap([], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap([], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_compiler_Resolver.ResolverState(2), lspHook_)
122
122
  }
123
123
 
124
+ export function checkDuplicates_(items_, name_, at_) {
125
+ let seen_ = ff_core_Map.new_();
126
+ ff_core_List.List_map(items_, ((item_) => {
127
+ const n_ = name_(item_);
128
+ if(ff_core_Map.Map_contains(seen_, n_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) {
129
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_(item_), ("Duplicate definition: " + n_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
130
+ };
131
+ seen_ = ff_core_Map.Map_add(seen_, n_, item_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
132
+ }));
133
+ return items_
134
+ }
135
+
124
136
  export async function new_$(packagePair_, moduleName_, lspHook_, $task) {
125
137
  return ff_compiler_Resolver.Resolver(ff_core_List.List_toMap([], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap([], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap([], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap([], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap([], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap([], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toSet([], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toSet([], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap([], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_core_List.List_toMap([], ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ff_compiler_Resolver.ResolverState(2), lspHook_)
126
138
  }
127
139
 
140
+ export async function checkDuplicates_$(items_, name_, at_, $task) {
141
+ let seen_ = ff_core_Map.new_();
142
+ (await ff_core_List.List_map$(items_, (async (item_, $task) => {
143
+ const n_ = (await name_(item_, $task));
144
+ if(ff_core_Map.Map_contains(seen_, n_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) {
145
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError((await at_(item_, $task)), ("Duplicate definition: " + n_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
146
+ };
147
+ seen_ = ff_core_Map.Map_add(seen_, n_, item_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
148
+ }), $task));
149
+ return items_
150
+ }
151
+
128
152
  export function Resolver_freshUnificationVariable(self_, at_) {
129
153
  const result_ = ff_compiler_Syntax.TVariable(at_, self_.state_.nextUnificationVariableIndex_);
130
154
  self_.state_.nextUnificationVariableIndex_ += 3;
@@ -139,21 +163,74 @@ return (_w1 !== 46)
139
163
  }));
140
164
  const self2_ = ff_compiler_Resolver.Resolver_processImports(self_, module_.imports_, otherModules_);
141
165
  const self3_ = ff_compiler_Resolver.Resolver_processDefinitions(self2_, module_, ff_core_Option.None());
166
+ const errors_ = ff_core_Array.new_();
142
167
  const module2_ = (((_c) => {
143
- return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, _c.imports_, 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) => {
144
169
  return ff_compiler_Resolver.Resolver_resolveTypeDefinition(self3_, _w1)
145
- })), ff_core_List.List_map(module_.traits_, ((_w1) => {
170
+ })), ff_compiler_Syntax.catchManyInto_(errors_, module_.traits_, ((_w1) => {
146
171
  return ff_compiler_Resolver.Resolver_resolveTraitDefinition(self3_, _w1)
147
- })), ff_core_List.List_map(module_.instances_, ((_w1) => {
172
+ })), ff_compiler_Syntax.catchManyInto_(errors_, module_.instances_, ((_w1) => {
148
173
  return ff_compiler_Resolver.Resolver_resolveInstanceDefinition(self3_, _w1)
149
- })), ff_core_List.List_map(module_.extends_, ((_w1) => {
174
+ })), ff_compiler_Syntax.catchManyInto_(errors_, module_.extends_, ((_w1) => {
150
175
  return ff_compiler_Resolver.Resolver_resolveExtendDefinition(self3_, _w1)
151
- })), ff_core_List.List_map(module_.lets_, ((_w1) => {
176
+ })), ff_compiler_Syntax.catchManyInto_(errors_, module_.lets_, ((_w1) => {
152
177
  return ff_compiler_Resolver.Resolver_resolveLetDefinition(self3_, _w1, true)
153
- })), ff_core_List.List_map(module_.functions_, ((_w1) => {
178
+ })), ff_compiler_Syntax.catchManyInto_(errors_, module_.functions_, ((_w1) => {
154
179
  return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self3_, _w1, true, false)
155
180
  })))
156
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) => {
201
+ return _w1.name_
202
+ }), ((_w1) => {
203
+ return _w1.at_
204
+ }));
205
+ ff_compiler_Resolver.checkDuplicates_(module2_.traits_, ((_w1) => {
206
+ return _w1.name_
207
+ }), ((_w1) => {
208
+ return _w1.at_
209
+ }));
210
+ ff_compiler_Resolver.checkDuplicates_(module2_.lets_, ((_w1) => {
211
+ return _w1.name_
212
+ }), ((_w1) => {
213
+ return _w1.at_
214
+ }));
215
+ ff_compiler_Resolver.checkDuplicates_(module2_.functions_, ((_w1) => {
216
+ return _w1.signature_.name_
217
+ }), ((_w1) => {
218
+ return _w1.at_
219
+ }));
220
+ const groupedExtendMethods_ = ff_core_List.List_group(ff_core_List.List_map(module2_.extends_, ((x_) => {
221
+ return ff_core_Pair.Pair(ff_core_String.String_takeWhile(ff_compiler_Syntax.Type_show(x_.type_, []), ((_w1) => {
222
+ return ff_core_Char.Char_isAsciiLetterOrDigit(_w1)
223
+ })), x_.methods_)
224
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
225
+ ff_core_List.List_map(ff_core_List.List_map(ff_core_Map.Map_values(groupedExtendMethods_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ((_w1) => {
226
+ return ff_core_List.List_flatten(_w1)
227
+ })), ((methods_) => {
228
+ return ff_compiler_Resolver.checkDuplicates_(methods_, ((_w1) => {
229
+ return _w1.signature_.name_
230
+ }), ((_w1) => {
231
+ return _w1.at_
232
+ }))
233
+ }));
157
234
  for(let for_a = module2_.instances_, for_i = 0, for_l = for_a.length; for_i < for_l; for_i++) {
158
235
  const _w1 = for_a[for_i];
159
236
  for(let for_a = _w1.typeArguments_, for_i = 0, for_l = for_a.length; for_i < for_l; for_i++) {
@@ -338,7 +415,7 @@ const _1 = definition_;
338
415
  const _c = _1;
339
416
  return ff_compiler_Syntax.DType(_c.at_, _c.newtype_, _c.data_, _c.name_, _c.generics_, ff_core_List.List_map(definition_.constraints_, ((_w1) => {
340
417
  return ff_compiler_Resolver.Resolver_resolveConstraint(self2_, _w1, true)
341
- })), ff_core_List.List_map(definition_.commonFields_, ((f_) => {
418
+ })), ff_compiler_Resolver.checkDuplicates_(ff_core_List.List_map(definition_.commonFields_, ((f_) => {
342
419
  const valueType_ = ff_compiler_Resolver.Resolver_resolveType(self2_, f_.valueType_, true);
343
420
  if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, f_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, f_.at_))) {
344
421
  ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveVariantFieldHook(ff_compiler_LspHook.SymbolHook(f_.name_, f_.at_, f_.at_), valueType_, true))
@@ -353,10 +430,19 @@ return ff_compiler_Resolver.Resolver_resolveTerm(self2_, _w1, true, false)
353
430
  return
354
431
  }
355
432
  }
356
- })), ff_core_List.List_map(definition_.variants_, ((v_) => {
433
+ })), ((_w1) => {
434
+ return _w1.name_
435
+ }), ((_w1) => {
436
+ return _w1.at_
437
+ })), ff_compiler_Resolver.checkDuplicates_(ff_core_List.List_map(definition_.variants_, ((v_) => {
357
438
  if(ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, v_.at_)) {
358
439
  ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(v_.name_, v_.at_, v_.at_), ff_core_Option.None(), true))
359
440
  };
441
+ ff_compiler_Resolver.checkDuplicates_([...definition_.commonFields_, ...v_.fields_], ((_w1) => {
442
+ return _w1.name_
443
+ }), ((_w1) => {
444
+ return _w1.at_
445
+ }));
360
446
  {
361
447
  const _1 = v_;
362
448
  {
@@ -380,6 +466,10 @@ return
380
466
  return
381
467
  }
382
468
  }
469
+ })), ((_w1) => {
470
+ return _w1.name_
471
+ }), ((_w1) => {
472
+ return _w1.at_
383
473
  })))
384
474
  return
385
475
  }
@@ -402,8 +492,12 @@ const _1 = definition_;
402
492
  const _c = _1;
403
493
  return ff_compiler_Syntax.DTrait(_c.at_, _c.name_, _c.generics_, ff_core_List.List_map(definition_.constraints_, ((_w1) => {
404
494
  return ff_compiler_Resolver.Resolver_resolveConstraint(self2_, _w1, true)
405
- })), _c.generatorParameters_, ff_core_List.List_map(definition_.methods_, ((_w1) => {
495
+ })), _c.generatorParameters_, ff_compiler_Resolver.checkDuplicates_(ff_core_List.List_map(definition_.methods_, ((_w1) => {
406
496
  return ff_compiler_Resolver.Resolver_resolveSignature(self2_, _w1, true, false)
497
+ })), ((_w1) => {
498
+ return _w1.name_
499
+ }), ((_w1) => {
500
+ return _w1.at_
407
501
  })), ff_core_List.List_map(definition_.methodDefaults_, ((_1) => {
408
502
  {
409
503
  const name_ = _1.first_;
@@ -1070,21 +1164,74 @@ return (_w1 !== 46)
1070
1164
  }));
1071
1165
  const self2_ = ff_compiler_Resolver.Resolver_processImports(self_, module_.imports_, otherModules_);
1072
1166
  const self3_ = ff_compiler_Resolver.Resolver_processDefinitions(self2_, module_, ff_core_Option.None());
1167
+ const errors_ = ff_core_Array.new_();
1073
1168
  const module2_ = (((_c) => {
1074
- return ff_compiler_Syntax.Module(_c.file_, _c.packagePair_, _c.imports_, 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) => {
1075
1170
  return ff_compiler_Resolver.Resolver_resolveTypeDefinition(self3_, _w1)
1076
- })), ff_core_List.List_map(module_.traits_, ((_w1) => {
1171
+ })), ff_compiler_Syntax.catchManyInto_(errors_, module_.traits_, ((_w1) => {
1077
1172
  return ff_compiler_Resolver.Resolver_resolveTraitDefinition(self3_, _w1)
1078
- })), ff_core_List.List_map(module_.instances_, ((_w1) => {
1173
+ })), ff_compiler_Syntax.catchManyInto_(errors_, module_.instances_, ((_w1) => {
1079
1174
  return ff_compiler_Resolver.Resolver_resolveInstanceDefinition(self3_, _w1)
1080
- })), ff_core_List.List_map(module_.extends_, ((_w1) => {
1175
+ })), ff_compiler_Syntax.catchManyInto_(errors_, module_.extends_, ((_w1) => {
1081
1176
  return ff_compiler_Resolver.Resolver_resolveExtendDefinition(self3_, _w1)
1082
- })), ff_core_List.List_map(module_.lets_, ((_w1) => {
1177
+ })), ff_compiler_Syntax.catchManyInto_(errors_, module_.lets_, ((_w1) => {
1083
1178
  return ff_compiler_Resolver.Resolver_resolveLetDefinition(self3_, _w1, true)
1084
- })), ff_core_List.List_map(module_.functions_, ((_w1) => {
1179
+ })), ff_compiler_Syntax.catchManyInto_(errors_, module_.functions_, ((_w1) => {
1085
1180
  return ff_compiler_Resolver.Resolver_resolveFunctionDefinition(self3_, _w1, true, false)
1086
1181
  })))
1087
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) => {
1202
+ return _w1.name_
1203
+ }), ((_w1) => {
1204
+ return _w1.at_
1205
+ }));
1206
+ ff_compiler_Resolver.checkDuplicates_(module2_.traits_, ((_w1) => {
1207
+ return _w1.name_
1208
+ }), ((_w1) => {
1209
+ return _w1.at_
1210
+ }));
1211
+ ff_compiler_Resolver.checkDuplicates_(module2_.lets_, ((_w1) => {
1212
+ return _w1.name_
1213
+ }), ((_w1) => {
1214
+ return _w1.at_
1215
+ }));
1216
+ ff_compiler_Resolver.checkDuplicates_(module2_.functions_, ((_w1) => {
1217
+ return _w1.signature_.name_
1218
+ }), ((_w1) => {
1219
+ return _w1.at_
1220
+ }));
1221
+ const groupedExtendMethods_ = ff_core_List.List_group(ff_core_List.List_map(module2_.extends_, ((x_) => {
1222
+ return ff_core_Pair.Pair(ff_core_String.String_takeWhile(ff_compiler_Syntax.Type_show(x_.type_, []), ((_w1) => {
1223
+ return ff_core_Char.Char_isAsciiLetterOrDigit(_w1)
1224
+ })), x_.methods_)
1225
+ })), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1226
+ ff_core_List.List_map(ff_core_List.List_map(ff_core_Map.Map_values(groupedExtendMethods_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ((_w1) => {
1227
+ return ff_core_List.List_flatten(_w1)
1228
+ })), ((methods_) => {
1229
+ return ff_compiler_Resolver.checkDuplicates_(methods_, ((_w1) => {
1230
+ return _w1.signature_.name_
1231
+ }), ((_w1) => {
1232
+ return _w1.at_
1233
+ }))
1234
+ }));
1088
1235
  for(let for_a = module2_.instances_, for_i = 0, for_l = for_a.length; for_i < for_l; for_i++) {
1089
1236
  const _w1 = for_a[for_i];
1090
1237
  for(let for_a = _w1.typeArguments_, for_i = 0, for_l = for_a.length; for_i < for_l; for_i++) {
@@ -1269,7 +1416,7 @@ const _1 = definition_;
1269
1416
  const _c = _1;
1270
1417
  return ff_compiler_Syntax.DType(_c.at_, _c.newtype_, _c.data_, _c.name_, _c.generics_, ff_core_List.List_map(definition_.constraints_, ((_w1) => {
1271
1418
  return ff_compiler_Resolver.Resolver_resolveConstraint(self2_, _w1, true)
1272
- })), ff_core_List.List_map(definition_.commonFields_, ((f_) => {
1419
+ })), ff_compiler_Resolver.checkDuplicates_(ff_core_List.List_map(definition_.commonFields_, ((f_) => {
1273
1420
  const valueType_ = ff_compiler_Resolver.Resolver_resolveType(self2_, f_.valueType_, true);
1274
1421
  if((ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, f_.at_) || ff_compiler_LspHook.LspHook_isDefinedAt(self_.lspHook_, f_.at_))) {
1275
1422
  ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveVariantFieldHook(ff_compiler_LspHook.SymbolHook(f_.name_, f_.at_, f_.at_), valueType_, true))
@@ -1284,10 +1431,19 @@ return ff_compiler_Resolver.Resolver_resolveTerm(self2_, _w1, true, false)
1284
1431
  return
1285
1432
  }
1286
1433
  }
1287
- })), ff_core_List.List_map(definition_.variants_, ((v_) => {
1434
+ })), ((_w1) => {
1435
+ return _w1.name_
1436
+ }), ((_w1) => {
1437
+ return _w1.at_
1438
+ })), ff_compiler_Resolver.checkDuplicates_(ff_core_List.List_map(definition_.variants_, ((v_) => {
1288
1439
  if(ff_compiler_LspHook.LspHook_isAt(self_.lspHook_, v_.at_)) {
1289
1440
  ff_compiler_LspHook.LspHook_emit(self_.lspHook_, ff_compiler_LspHook.ResolveSymbolHook(ff_compiler_LspHook.SymbolHook(v_.name_, v_.at_, v_.at_), ff_core_Option.None(), true))
1290
1441
  };
1442
+ ff_compiler_Resolver.checkDuplicates_([...definition_.commonFields_, ...v_.fields_], ((_w1) => {
1443
+ return _w1.name_
1444
+ }), ((_w1) => {
1445
+ return _w1.at_
1446
+ }));
1291
1447
  {
1292
1448
  const _1 = v_;
1293
1449
  {
@@ -1311,6 +1467,10 @@ return
1311
1467
  return
1312
1468
  }
1313
1469
  }
1470
+ })), ((_w1) => {
1471
+ return _w1.name_
1472
+ }), ((_w1) => {
1473
+ return _w1.at_
1314
1474
  })))
1315
1475
  return
1316
1476
  }
@@ -1333,8 +1493,12 @@ const _1 = definition_;
1333
1493
  const _c = _1;
1334
1494
  return ff_compiler_Syntax.DTrait(_c.at_, _c.name_, _c.generics_, ff_core_List.List_map(definition_.constraints_, ((_w1) => {
1335
1495
  return ff_compiler_Resolver.Resolver_resolveConstraint(self2_, _w1, true)
1336
- })), _c.generatorParameters_, ff_core_List.List_map(definition_.methods_, ((_w1) => {
1496
+ })), _c.generatorParameters_, ff_compiler_Resolver.checkDuplicates_(ff_core_List.List_map(definition_.methods_, ((_w1) => {
1337
1497
  return ff_compiler_Resolver.Resolver_resolveSignature(self2_, _w1, true, false)
1498
+ })), ((_w1) => {
1499
+ return _w1.name_
1500
+ }), ((_w1) => {
1501
+ return _w1.at_
1338
1502
  })), ff_core_List.List_map(definition_.methodDefaults_, ((_1) => {
1339
1503
  {
1340
1504
  const name_ = _1.first_;
@@ -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.43",
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.43",
7
+ "version": "0.5.45",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/Ahnfelt/firefly-boot"