rdicosmo / parmap

Parmap is a minimalistic library allowing to exploit multicore architecture for OCaml programs with minimal modifications.
http://rdicosmo.github.io/parmap/
Other
94 stars 20 forks source link

silence the -unerasable-optional-argument warning about Parmap.redirect #109

Closed gasche closed 1 year ago

gasche commented 1 year ago

Parmap.redirect, introduced in 236137fb12dd84b8d60bd7f6f9496d6032f85df2, has an optional argument that is not followed by any non-labelled argument. With this interface, OCaml can never deduce that the optional argument will never be passed by the user, so users have to use ?path:None explicitly to not pass a path.

One could fix this issue by making ~id a non-labelled argument, or by adding a dummy unit argument at the end.

The present commit simply silences the warning, which restores the build under OCaml 4.12 and later versions. The reason why this code only started failing in 4.12 is that the pre-4.12 implementation of the unerasable-optional-argument warning did not detect this case, and the warning check was widened for 4.12 by https://github.com/ocaml/ocaml/pull/9783

Ideally it would be nice to change the interface of Parmap.redirect, but this would be an API-breaking change.

rdicosmo commented 1 year ago

Thanks @gasche for spotting this and the workaround. For the moment, I would like to avoid API breaking changes.