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
--------------------------------------------------------------------------------
No unused method is reported although factory#unused should be. 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
--------------------------------------------------------------------------------
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
No unused method is reported although
factory#unusedshould be. Without the binding toresinfactory, the results are: