Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing labels in generated applications in Typecore.type_argument #5800

Closed
vicuna opened this issue Oct 27, 2012 · 4 comments
Closed

missing labels in generated applications in Typecore.type_argument #5800

vicuna opened this issue Oct 27, 2012 · 4 comments
Assignees

Comments

@vicuna
Copy link

vicuna commented Oct 27, 2012

Original bug ID: 5800
Reporter: turpin
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2015-12-11T18:08:17Z)
Resolution: fixed
Priority: low
Severity: trivial
Version: 4.00.1
Fixed in version: 4.00.2+dev
Category: typing

Bug description

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...

File attachments

@vicuna
Copy link
Author

vicuna commented Oct 29, 2012

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.)

@vicuna
Copy link
Author

vicuna commented Oct 29, 2012

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 ?

@vicuna
Copy link
Author

vicuna commented Oct 30, 2012

Comment author: @garrigue

This was already fixed in trunk by Alain, but I cannot find it in Mantis.
Anyway, I merged Alain's fix (commits 12919 and 12920) in 4.00@13050.

@vicuna
Copy link
Author

vicuna commented Oct 30, 2012

Comment author: @garrigue

At 13050 in 4.00 and 12919-12920 in trunk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants