Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No warning for partly evaluated functions at toplevel #6236

Closed
vicuna opened this issue Nov 13, 2013 · 5 comments
Closed

No warning for partly evaluated functions at toplevel #6236

vicuna opened this issue Nov 13, 2013 · 5 comments

Comments

@vicuna
Copy link

vicuna commented Nov 13, 2013

Original bug ID: 6236
Reporter: gmelquiond
Status: acknowledged (set by @damiendoligez on 2013-11-30T22:28:26Z)
Resolution: open
Priority: normal
Severity: feature
Version: 4.00.1
Category: typing

Bug description

let f ~a b = failwith b
let _ = f "success"

The compiler emits no warning about the last line not being executed completely. The bug looks obvious on this testcase, but it is mind-boggling on a larger piece of code spanning several files. (We had it occur in Why3 recently.)

So it would be great if warning 5 ("this function application is partial, maybe some arguments are missing") was also emitted for anonymous let-statements at top level. (I know that, if "let ()" had been used instead, the compiler would have complained loudly.)

@vicuna
Copy link
Author

vicuna commented Nov 13, 2013

Comment author: @garrigue

Intentionally, let _ = expr does not cause any warning.
Using it is at top-level is bad practice.
You should either write
let () = ...
or
let () = ignore (...)
which will both warn you.

@vicuna
Copy link
Author

vicuna commented Nov 14, 2013

Comment author: @alainfrisch

What about a new warning on all "let _ = ..." bindings? In my opinion, even for local bindings, it is bad style.

@vicuna
Copy link
Author

vicuna commented Feb 19, 2014

Comment author: @damiendoligez

Please let us not multiply coding-style warnings that could easily be implemented by an external tool. In this case, even emacs should be able to warn you.

@github-actions
Copy link

This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc.

@github-actions github-actions bot added the Stale label May 15, 2020
@yallop
Copy link
Member

yallop commented May 15, 2020

This has been fixed by #1974, released in OCaml 4.08:

$ cat partial.ml 
let f ~a b = failwith b
let _ = f "success"
$ ocamlc partial.ml 
File "partial.ml", line 2, characters 8-19:
2 | let _ = f "success"
            ^^^^^^^^^^^
Warning 5: this function application is partial,
maybe some arguments are missing.

@yallop yallop closed this as completed May 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants