You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A new idea for a rule: is a possible to check if the function close_in (resp. close_out) is always called for each opened in_channel (resp. out_channel) before the end of its lifetime?
We can assume that it should be done in the same scope as the open_in (resp. open_out).
Examples:
let f name =
try
let out = open_out name in
let text = compute_something () in
output_string out text;
close_out out
with _ ->
Format.eprintf "Error@."
Should warn about not closing out if an exception is raised between the open and close.
let f name =
let out = open_out name in
try
let text = compute_something () in
output_string out text;
close_out out
with _ ->
Format.eprintf "Error@.";
close_out out
Should be ok.
let f name =
try
let out = open_out name in
compute_something out
with _ ->
Format.eprintf "Error@."
Should warn even if out is always closed in compute_something.
What do you think about this?
Comments (even negative ones!) and suggestions are welcome.
The text was updated successfully, but these errors were encountered:
A new idea for a rule: is a possible to check if the function
close_in
(resp.close_out
) is always called for each openedin_channel
(resp.out_channel
) before the end of its lifetime?We can assume that it should be done in the same scope as the
open_in
(resp.open_out
).Examples:
Should warn about not closing
out
if an exception is raised between theopen
andclose
.Should be ok.
Should warn even if
out
is always closed incompute_something
.What do you think about this?
Comments (even negative ones!) and suggestions are welcome.
The text was updated successfully, but these errors were encountered: