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: 7429 Reporter:@lpw25 Assigned to:@lpw25 Status: resolved (set by @lpw25 on 2016-12-07T16:12:59Z) Resolution: not a bug Priority: normal Severity: minor Version: 4.04.0 Category: typing Related to:#6738 Monitored by:@gasche
Bug description
The following code:
let rec x = lazy (subscribe (fun _ -> (Lazy.force x)));;
produces an unused value warning for x if it is not used in the rest of the program. However, the binding to x is required in this case.
Obviously, the warning is trying to make sure that things like recursive function definitions do not get automatically marked as used just because they are recursive, but it seems that the issue is subtler than how the current check works.
This code is pretty unusual, and the work-around is easy (simply rename x to _x) so it may not be worth fixing if the criteria is too complicated.
The text was updated successfully, but these errors were encountered:
The point is that the declaration is not useless. The subscribe function is side-effecting and returns a value that we wish to use inside the function passed to subscribe.
Ok, I've had a look at the original code and it seems that it would not compile. It was equivalent to:
let rec x = subscribe (fun _ -> x);;
The confusion seems to have come from the fact that you get the warning about it being unused before you get the error about it not compiling.
So basically the warning is overly aggressive, but only on programs that are inappropriately recursive. In which case, this bug report is just a duplicate of the general complaint that recursion errors are handled after type-checking.
Original bug ID: 7429
Reporter: @lpw25
Assigned to: @lpw25
Status: resolved (set by @lpw25 on 2016-12-07T16:12:59Z)
Resolution: not a bug
Priority: normal
Severity: minor
Version: 4.04.0
Category: typing
Related to: #6738
Monitored by: @gasche
Bug description
The following code:
let rec x = lazy (subscribe (fun _ -> (Lazy.force x)));;
produces an unused value warning for
x
if it is not used in the rest of the program. However, the binding tox
is required in this case.Obviously, the warning is trying to make sure that things like recursive function definitions do not get automatically marked as used just because they are recursive, but it seems that the issue is subtler than how the current check works.
This code is pretty unusual, and the work-around is easy (simply rename
x
to_x
) so it may not be worth fixing if the criteria is too complicated.The text was updated successfully, but these errors were encountered: