Make warnings and errors stricter by default
The request here is to start people off with a set of stricter default warnings and errors from bsb -init; since we expect most people to start with a scaffold from bsb -init, it's a great way to start off with enhanced safety from OCaml. I am proposing the following configuration:
"warnings": {
"number": "+A-48",
"error": "+A-3-44-102"
}
I believe this is a reasonable default:
- show all warnings except 'implicit elimination of optional arguments'
- make all warnings errors except deprecation, 'Open statement shadows an already defined identifier', and polymorphic comparisons.
Dune set the precedent and I think it's a good one.
Do you have a link to the dune default I did spend some time in current default setting, in particular, which warning do you think is missing compared with current setting
Sure, here is the dune default (as of right now): https://github.com/ocaml/dune/blob/51b0e5f326710a833ee2679095b53902488ef7b5/src/ocaml_flags.ml#L8
What I miss in particular:
- Missing .cmi
- But I mostly miss that nearly everything is just a warning and not an error.
Most of these warnings are telling you about things you almost certainly don't want to have in your codebase, especially as a beginner when you're unsure of best practices. I think BuckleScript setting a good default here could be very helpful, same justification as dune.
Missing .cmi is a new warning? We can add it, PR is welcome.
everything is just a warning and not an error. The thing is most compilers like gcc does not have warn-error enabled by default
It's an existing warning, 49: https://dev.to/yawaramin/bucklescript-best-practice-public-and-private-modules-5ald#the-raw-no-cmi-file-endraw-warningand-error . It warns you that a .cmi was not found when you try to use a private module.
Regarding warn-error by default, that is true and neither does ocamlc/ocamlopt/bsc :-) What I am suggesting is to turn it on by default at the build level for BuckleScript's scaffolded bsconfig.json. This would directly benefit new users most but it would steer everyone towards best practices. We can also provide a comment showing how to make the settings less strict if people need to.
I agree with @yawaramin here, I think warnings are really good, specially when coming from a background where you don't know OCaml the warnings are hints for idiomatic code. Also, the disparity between my editor showing the warning and the compiler not showing anything is really, really weird.
If I'm not mistaken, default warnings need to be adapted here https://github.com/rescript-lang/rescript-compiler/blob/25753edc9d935a24100d7ee488ad4592e097a82f/jscomp/ext/bsc_warnings.ml#L75 ?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.