Skip to content
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

Fix a few error reports #784

Merged
merged 12 commits into from
Nov 25, 2021
Merged

Conversation

jonludlam
Copy link
Member

And other miscellaneous fixes.

Copy link
Collaborator

@Julow Julow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs formatting ! (dune build @fmt does format the dune files too)

@@ -75,7 +75,7 @@ let report_internal fmt = report ~non_fatal:true fmt

let report_root ~name = add (`Root name)

let report_warning fmt = report ~non_fatal:false fmt
let report_warning fmt = report ~non_fatal:true fmt
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is whether the warning is not-affected by the "warn error" mode, it should stay false. The correct fix for the prefixes is #785

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh? so warn-error doesn't make all warnings errors? That doesn't make sense, does it?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some warning are never turned into errors indeed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"internal" warnings (most errors from linking) are never turned into fatal errors, as well as failures to lookup root modules.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surely in that case it's an 'info' message rather than a warning, at the very least so people know the meaning of --warn-error

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's because these errors are caused by complicated things and the user can't really fix (bugs in odoc, things expected in the environment that Dune never give).
These things can be fixed but not for 2.0.1.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made #786 to sort this out, and added it to the 2.1 release project.

@@ -103,7 +103,8 @@ module Tools_error = struct
| simple_module_type_expr_of_module_error
| simple_module_lookup_error
| signature_of_module_error
| parent_lookup_error ]
| parent_lookup_error
| reference_lookup_error ]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This diff is not necessary.
Reference errors are wrapped in "parent errors" because references are kind of an other language, errors don't mix.

Revert:

diff --git a/src/xref2/errors.ml b/src/xref2/errors.ml
index afba115b7..55469d03b 100644
--- a/src/xref2/errors.ml
+++ b/src/xref2/errors.ml
@@ -103,8 +103,7 @@ module Tools_error = struct
     | simple_module_type_expr_of_module_error
     | simple_module_lookup_error
     | signature_of_module_error
-    | parent_lookup_error
-    | reference_lookup_error ]
+    | parent_lookup_error ]
 
   let pp_reference_kind fmt k =
     let k =
@@ -166,7 +165,9 @@ module Tools_error = struct
     | `Parent_module e -> Format.fprintf fmt "Parent_module: %a" pp (e :> any)
     | `Fragment_root -> Format.fprintf fmt "Fragment root"
     | `Parent_type e -> Format.fprintf fmt "Parent_type: %a" pp (e :> any)
-    | `Reference e -> pp fmt (e :> any)
+    | `Reference e -> pp_reference_lookup_error fmt e
+
+  and pp_reference_lookup_error fmt = function
     | `Wrong_kind (expected, got) ->
         let pp_sep fmt () = Format.fprintf fmt " or " in
         Format.fprintf fmt "is of kind %a but expected %a" pp_reference_kind got
@@ -178,6 +179,7 @@ module Tools_error = struct
         | #reference_kind as kind ->
             Format.fprintf fmt "Couldn't find %a %S" pp_reference_kind kind name
         )
+    | `Parent e -> pp fmt (e :> any)
 end
 
 (* Ugh. we need to determine whether this was down to an unexpanded module type error. This is horrendous. *)
@@ -210,9 +212,6 @@ let is_unexpanded_module_type_of =
     | `OpaqueClass -> false
     | `Reference (`Parent p) -> inner (p :> any)
     | `Reference _ -> false
-    | `Wrong_kind _ -> false
-    | `Lookup_by_name _ -> false
-    | `Find_by_name _ -> false
   in
   inner
 
@@ -246,7 +245,6 @@ let rec kind_of_error : Tools_error.any -> kind option = function
   | `Parent (`Parent_expr e) -> kind_of_error (e :> Tools_error.any)
   | `Parent (`Parent_module e) -> kind_of_error (e :> Tools_error.any)
   | `Parent (`Parent _ as e) -> kind_of_error (e :> Tools_error.any)
-  | `Reference e -> kind_of_error (e :> Tools_error.any)
   | `OpaqueModule ->
       (* Don't turn OpaqueModule warnings into errors *)
       Some `OpaqueModule

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why on earth are reference errors 'parent' errors? That doesn't make sense either.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's how the errors are constructed and destructed currently. I have a work-in-progress patch that entirely remove the "parent" thing but it's far from ready (https://github.com/Julow/odoc/tree/imp-tools-errors)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ugh. OK, let's leave it as-is for now and sort it out in 2.1

There's an issue somewhere meaning that sometimes shadowed items
end up aren't marked as such - for example `compare` in
`ocaml.git/middle_end/backend_var.mli`. Rather than turn that into
a hard error just re-enable the duplication for now.
Now using OCaml 4.12.1 (with lots of new reference resolution
failures to report!)
But leave it there because it indicates a problem!
@jonludlam jonludlam force-pushed the fix-a-few-error-reports branch from 7f5845a to 9103f13 Compare November 25, 2021 12:57
Copy link
Collaborator

@Julow Julow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants