-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
Context
If a factory function binds its result (with or without manipulating the binding) before returning it, then its methods are not tracked.
Example and reproduction
(* /tmp/bind_before_return/bind_before_return.ml *)
let factory () =
let res =
object
method used = ()
method unused = ()
end
in
res
let () = (factory ())#used$ ocamlopt -bin-annot bind_before_return.ml
$ dead_code_analyzer --nothing -M all bind_before_return.cmi bind_before_return.cmt
Scanning files...
[DONE]
.> UNUSED METHODS:
=================
Nothing else to report in this section
--------------------------------------------------------------------------------
We can see that there is not unused method reported although factory#unused should be reported. Without the binding to res in factory, the results are:
Scanning files...
[DONE]
.> UNUSED METHODS:
=================
/tmp/bind_before_return/bind_before_return.ml:2: factory#unused
Nothing else to report in this section
--------------------------------------------------------------------------------
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels