rescript-association / reanalyze

Experimental analyses for ReScript and OCaml: globally dead values/types, exception analysis, and termination analysis.
MIT License
277 stars 20 forks source link

Interpret OCaml compiler's unused value declaration warning suppression attribute #154

Closed sim642 closed 2 years ago

sim642 commented 2 years ago

Running reanalyze https://github.com/rescript-association/reanalyze/commit/389dd682223201b42c33e5c444e5c79e0805adad on Goblint https://github.com/goblint/analyzer/commit/a544002114324a207df72f9e79eb656c3ebe7b5b revealed the following.

We have a definition for which the OCaml compiler's unused value declaration warning is suppressed:

  let[@warning "-unused-value-declaration"] print_path ch = function
    | Select (s,p) -> fprintf ch "%s%a" s print_path' p
    | pth -> print_path' ch pth [@@dead "Impl.+print_path"] 

Reanalyze of course also finds it dead.

It would be neat, if reanalyze recognized the attribute used for suppressing the warning for the compiler also itself and wouldn't complain about it. Right now such declaration would require both attributes to keep both tools quiet.

cristianoc commented 2 years ago

I think there is a provision for recognising "-32" easily adaptable to include the format used in the example above.