Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Do something with *predef*.option #6611
Original bug ID: 6611
Currently, the types of all optional arguments in function signatures must be wrapped in an internal "predef option" type, which can be done with this function:
This is extremely unintuitive. The compiler will normally show types not wrapped in "predef option" as "" and complain that the function does not match its signature. In fact, it cost me an hour of debugging before I accidentally looked at Pprintast and noticed an assertion that checks for "predef option".
There are two ways to fix this that I can see.
Comment author: @alainfrisch
I'd go for 1), which is technically very simple: just move the code which adds the predef.option wrapper from parser.mly to typetexp.ml/typeclass.ml (in the cases for Ptyp_arrow/Pcty_arrow). But this cannot be done lightly, since it would break for instance camlp4/camlp5. One more backward compatible change would be to add the wrapper only if it is not already present in the Parsetree.
I've added a patch which does that (untested), but this seems too risky to go into 4.02.1.