Warnings enabled by default

Hi,
The recent and exciting changes of warning handling got me thinking: https://forum.rescript-lang.org/t/move-forward-with-warn-as-error-by-default

  • Which warnings are enabled by default?
  • Which warnings are seen as best practice to be enabled in the ocaml world?
  • Should the set of enabled warnings by default be changed in the light of them being errors now?
  • Would it be a good idea to introduce some kind of “warning presets” additionally / instead of listing separate warning numbers to dis-/enable in bsconfig. Meaning to not list warning numbers but just write “all” / “default” / “none”. The obvious tradeoff being another “abstraction layer” and difference to ocaml vs usability for newcomers.

I’d like to hear thoughts of others.

I’ve written about this in the past, https://dev.to/yawaramin/ocaml-reasonml-best-practice-warnings-and-errors-4mkm

And also suggested that ReScript templates should have stricter settings for warnings: https://github.com/rescript-lang/rescript-compiler/issues/3471

3 Likes

Oh that reminds me, I have been meaning to follow up with you on -48 (optional argument erasure). I found some code in my project where making use of erasure produced JS that was bad enough to make me immediately re-enable the warning and undo the change.

I will dig through my notes soon and see if I can post some example code :thinking:

1 Like

I didn’t know about your raised issue, thanks!

Maybe I’ll find some time to come up with my first PR to rescript-compiler… :smiley:

1 Like

OK so it was an edge case and I’ll probably re-evaluate turning off warning 48 again soon. I can’t easily recreate this with sample code, but the problem is a function with optional arguments that returns a function.

It’s a three argument function, the first is optional. With a unit argument, the JS is:

return makeFunction(undefined, a, b, undefined)

Removing the unit argument at the end produces:

var arg = b;
return function (eta) {
  return Curry._1(makeFunction(undefined, a, arg), eta);
};

But I’m sure I can find a way around this mess (returning an uncurried function might do it).