-
Notifications
You must be signed in to change notification settings - Fork 470
Clean up Super_error #6199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean up Super_error #6199
Changes from 4 commits
8db4e2f
4b8c3ee
4ec6771
2bd9366
6a76c51
9706da8
10ac8c0
9d4e302
8d8bf81
4ecaeb3
2c24e15
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
[1;31mWe've found a bug for you![0m | ||
[36m/.../fixtures/repeated_def_extension_constr.res[0m:[2m3:6[0m | ||
|
||
1 [2m│[0m type a = .. | ||
2 [2m│[0m | ||
[1;31m3[0m [2m│[0m type [1;31ma[0m | ||
4 [2m│[0m | ||
|
||
Multiple definition of the type name a at line 1, characters 5-6. | ||
Names must be unique in a given structure or signature. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
[1;31mWe've found a bug for you![0m | ||
[36m/.../fixtures/repeated_def_module_types.res[0m:[2m3:13[0m | ||
|
||
1 [2m│[0m module type M = {} | ||
2 [2m│[0m | ||
[1;31m3[0m [2m│[0m module type [1;31mM[0m = {} | ||
4 [2m│[0m | ||
|
||
Multiple definition of the module type name M at line 1, characters 12-13. | ||
Names must be unique in a given structure or signature. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
[1;31mWe've found a bug for you![0m | ||
[36m/.../fixtures/repeated_def_modules.res[0m:[2m3:8[0m | ||
|
||
1 [2m│[0m module M = {} | ||
2 [2m│[0m | ||
[1;31m3[0m [2m│[0m module [1;31mM[0m = {} | ||
4 [2m│[0m | ||
|
||
Multiple definition of the module name M at line 1, characters 7-8. | ||
Names must be unique in a given structure or signature. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
[1;31mWe've found a bug for you![0m | ||
[36m/.../fixtures/repeated_def_types.res[0m:[2m3:6[0m | ||
|
||
1 [2m│[0m type a | ||
2 [2m│[0m | ||
[1;31m3[0m [2m│[0m type [1;31ma[0m | ||
4 [2m│[0m | ||
|
||
Multiple definition of the type name a at line 1, characters 5-6. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should say 1:6 for consistency. I think this is using ocaml locations, from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now I get it about error handling including super_error. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this test output has non changed yet? |
||
Names must be unique in a given structure or signature. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
type a = .. | ||
|
||
type a |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module type M = {} | ||
|
||
module type M = {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module M = {} | ||
|
||
module M = {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
type a | ||
|
||
type a |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ type error = | |
Longident.t * Path.t * Includemod.error list | ||
| With_changes_module_alias of Longident.t * Ident.t * Path.t | ||
| With_cannot_remove_constrained_type | ||
| Repeated_name of string * string | ||
| Repeated_name of string * string * Warnings.loc | ||
| Non_generalizable of type_expr | ||
| Non_generalizable_module of module_type | ||
| Interface_not_compiled of string | ||
|
@@ -623,25 +623,26 @@ let check_recmod_typedecls env sdecls decls = | |
module StringSet = | ||
Set.Make(struct type t = string let compare (x:t) y = String.compare x y end) | ||
|
||
let check cl loc set_ref name = | ||
if StringSet.mem name !set_ref | ||
then raise(Error(loc, Env.empty, Repeated_name(cl, name))) | ||
else set_ref := StringSet.add name !set_ref | ||
let check cl loc tbl name = | ||
match Hashtbl.find_opt tbl name with | ||
| Some repeated_loc -> | ||
raise(Error(loc, Env.empty, Repeated_name(cl, name, repeated_loc))) | ||
| None -> Hashtbl.add tbl name loc | ||
|
||
type names = | ||
{ | ||
types: StringSet.t ref; | ||
modules: StringSet.t ref; | ||
modtypes: StringSet.t ref; | ||
typexts: StringSet.t ref; | ||
types: (string, Warnings.loc) Hashtbl.t; | ||
modules: (string, Warnings.loc) Hashtbl.t; | ||
modtypes: (string, Warnings.loc) Hashtbl.t; | ||
typexts: (string, Warnings.loc) Hashtbl.t; | ||
} | ||
|
||
let new_names () = | ||
{ | ||
types = ref StringSet.empty; | ||
modules = ref StringSet.empty; | ||
modtypes = ref StringSet.empty; | ||
typexts = ref StringSet.empty; | ||
types = (Hashtbl.create 10); | ||
modules = (Hashtbl.create 10); | ||
modtypes = (Hashtbl.create 10); | ||
typexts = (Hashtbl.create 10); | ||
} | ||
|
||
|
||
|
@@ -1853,10 +1854,12 @@ let report_error ppf = function | |
"@[<v>Destructive substitutions are not supported for constrained @ \ | ||
types (other than when replacing a type constructor with @ \ | ||
a type constructor with the same arguments).@]" | ||
| Repeated_name(kind, name) -> | ||
| Repeated_name(kind, name, repeated_loc) -> | ||
let (_, start_line, start_char) = Location.get_pos_info repeated_loc.loc_start in | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would you check that these correspond to the locations printed normally (whether starting from 0 or 1) for other error messages? |
||
let (_, _, end_char) = Location.get_pos_info repeated_loc.loc_end in | ||
fprintf ppf | ||
"@[Multiple definition of the %s name %s.@ \ | ||
Names must be unique in a given structure or signature.@]" kind name | ||
"@[Multiple definition of the %s name %s at line %d, characters %d-%d.@ \ | ||
Names must be unique in a given structure or signature.@]" kind name start_line start_char end_char | ||
| Non_generalizable typ -> | ||
fprintf ppf | ||
"@[The type of this expression,@ %a,@ \ | ||
|
Uh oh!
There was an error while loading. Please reload this page.