You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/compiler/compiler.ml
+42-11Lines changed: 42 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -275,6 +275,7 @@ module Assembled = struct
275
275
kinds : Arity.tF.Map.t;
276
276
types : TypingEnv.t;
277
277
type_abbrevs : Type_checker.type_abbrevs;
278
+
ty_names : Loc.tF.Map.t;
278
279
}
279
280
[@@deriving show]
280
281
@@ -305,6 +306,7 @@ module Assembled = struct
305
306
types =TypingEnv.empty;
306
307
type_abbrevs =F.Map.empty;
307
308
toplevel_macros =F.Map.empty;
309
+
ty_names =F.Map.empty;
308
310
}
309
311
letempty()= {
310
312
clauses =[];
@@ -1038,6 +1040,12 @@ end = struct
1038
1040
let type_abbrevs =List.map compile_type_abbrev type_abbrevs in
1039
1041
let kinds =List.fold_left compile_kind F.Map.empty kinds in
1040
1042
let types =List.fold_left (funmt -> map_append TypingEnv.empty t (ScopeTypeExpressionUniqueList.make @@ compile_type t) m) F.Map.empty (List.rev types) in
1043
+
let ta_t_captures =List.filter_map (fun (k,loc) -> ifF.Map.mem k kinds thenSome (k,loc,F.Map.find k kinds) elseNone) type_abbrevs in
1044
+
if ta_t_captures <>[]thenbegin
1045
+
let ta, tsd, (_, oloc) =List.hd ta_t_captures in
1046
+
let tad =List.assoc ta type_abbrevs in
1047
+
error ~loc:tad.ScopedTypeExpression.loc ("Illegal type abbreviation for "^F.show ta ^". A type with the same name already exists in "^Loc.show oloc)
1048
+
end;
1041
1049
let defs_k = defs_of_map kinds in
1042
1050
let defs_t = defs_of_map types in
1043
1051
let defs_ta = defs_of_assoclist type_abbrevs in
@@ -1283,6 +1291,11 @@ module Flatten : sig
1283
1291
let types = merge_types TypingEnv.empty (apply_subst_types new_ty_subst t) types in
let { Assembled.toplevel_macros; kinds; types; type_abbrevs; ty_names } = signature in
2017
2045
let kinds =Flatten.merge_kinds ok kinds in
2046
+
F.Map.iter (funk (_,loc) -> ifF.Map.mem k ots &¬ (Loc.equal loc (F.Map.find k ots)) then error ~loc ("Illegal type abbreviation for "^F.show k ^". A type with the same name already exists in "^Loc.show (F.Map.find k ots))) type_abbrevs;
2018
2047
let type_abbrevs =Flatten.merge_checked_type_abbrevs ota type_abbrevs in
2019
2048
let types =Flatten.merge_type_assignments ot types in
2020
2049
let toplevel_macros =Flatten.merge_toplevel_macros types otlm toplevel_macros in
0 commit comments