Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
missing labels in generated applications in Typecore.type_argument #5800
Original bug ID: 5800
In Typecore.type_argument, Applications to "None" are generated to account for absent optional arguments, but the actual labels are not kept in this application. I believe that this just a mistake, which is fixed by the attached patch (only tested by bootstrapping successfully), but I admit that do not fully understand the code of the typechecker.
I assume that this has no effect on the backend, since labels are discarded anyway, but it matters for typedtree transformations.
Steps to reproduce
unparse the typedtree and recompile...
Comment author: @gasche
I think that the arguments are applied in the reverse order: if the function argument has type ?l1:t1 -> ?l2:t2 -> ?l3:t3 -> t -> u, then your patch produces the application (foo ~l3:None ~l2:None ~l1:None) (because "args" are acumulated by a tail-rec function in reverse position). This is correct as label order is not significant, but I would still have a preference for having the label order, in this generated code, mirror the order in the type, for easier readability of the resulting code.
Finally, it's the second time I've had to read this piece of code and it still made my head hurt. In the hope of helping future reviews of the code, I have written a more verbose comment about what it's doing (patch attached). Jacques, would you agree to include it in the code? (Do you have a policy for comments in general? Adding a tad more comment is something I sometimes wish to do when reading the type-checker code.)
Comment author: turpin
I didn't pay attention to the order of arguments, I didn't change the order in which they were produced but since the labels were missing we had "args = rev args", which is no longer true. Is the tail-recursion really needed here ? Who needs so many optional arguments ?