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
Original bug ID: 4960 Reporter:@mmottl Assigned to:@alainfrisch Status: closed (set by @alainfrisch on 2011-12-22T11:49:37Z) Resolution: duplicate Priority: normal Severity: minor Version: 3.11.1 Category: ~DO NOT USE (was: OCaml general) Child of:#5438 Monitored by: mehdi @ygrek "Julien Signoles" @hcarty yminsky @alainfrisch@mmottl
Bug description
The following function clearly does not make use of the recursive function "loop" in its body, i.e. this loop is dead code. Nevertheless the compiler does not warn about this, probably because the recursive call to "loop" is considered sufficient.
let f () =
let rec loop () =
print_endline "foo";
loop ()
in
42
The text was updated successfully, but these errors were encountered:
Another case of incompleteness of the warning is related to local open (even without the new explicit local open construction):
module A = struct let x = 1 end
let f () = let x = 2 in let module M = struct open A let a = x + 1 end in ()
Here the local "let x = ..." is not used. To see this, the check should be implemented in the type-checker, not as a purely syntactic pass. Doing the detection in the type-checker opens the door to more powerful detection of useless declaration (e.g. module components [types, values] which are not used internally and are hidden by the signature). We use such a patch at LexiFi, and it helped us find a lot of dead code and a few bugs.
Another example with classes:
class c = object val x = 1 end
let f () = let x = 2 in object inherit o method y = x end
or even, simply:
let f () = let x = 2 in object val x = 1 method y = x end
(this last example could probably be fixed even with the current syntactic approach).
Original bug ID: 4960
Reporter: @mmottl
Assigned to: @alainfrisch
Status: closed (set by @alainfrisch on 2011-12-22T11:49:37Z)
Resolution: duplicate
Priority: normal
Severity: minor
Version: 3.11.1
Category: ~DO NOT USE (was: OCaml general)
Child of: #5438
Monitored by: mehdi @ygrek "Julien Signoles" @hcarty yminsky @alainfrisch @mmottl
Bug description
The following function clearly does not make use of the recursive function "loop" in its body, i.e. this loop is dead code. Nevertheless the compiler does not warn about this, probably because the recursive call to "loop" is considered sufficient.
let f () =
let rec loop () =
print_endline "foo";
loop ()
in
42
The text was updated successfully, but these errors were encountered: