Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Make Tsubst directly retain two arguments, instead of nesting a Ttuple #10174
Make Tsubst directly retain two arguments, instead of nesting a Ttuple #10174
Changes from all commits
458882b
d5c2c03
2f8c0a8
02bb2da
2e1e69d
fa18e1a
4882078
1b86a27
0662c26
b8553b7
fa7f26d
1c0e65e
856f9cc
9b9d88e
7bbfd63
6a10cc3
c7d2ffa
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All code paths aware of the this tuple encoding (aka the pattern matching above and one in
Subst
) never usemore'
. Since all other users would erroneously interpret this encoding as a real tuple, it seems to me that rather than the producttype_expr * type_expr option
, the non-encoded argument ofTsubst
is a sum.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we were to just encode the current behavior of the algorithm in this type, you are correct.
However, it seems cleaner that the meaning of
Tsubst
be regular, i.e. its first argument is always a copy of the original node. Then the second argument is some special information used by the algorithm, here a copy of the enclosingTvariant
node.We can ensure that we do not depart from the current behavior of the algorithm by checking that this second argument is always
None
when we use the first one. We will add such assertions.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the record, I don't really understand what is going on here. I suppose there is a problem when
lbl_res
andlbl_args
share some parts of the type, but it's not clear who might introduceTsubst
. (I supposeinstance_poly
can introduce Tsubst nodes, andcopy
normalizes them away?)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the other way round:
copy_sep
(first phase ofinstance_poly
) does not introduce (and should not see)Tsubst
's, whilecopy
does. Could add an assertion incopy_sep
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could add many assertions in
copy_sep
, I don't think this PR is the one where we want to start doing that.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are already adding assertions about
Tsubst
everywhere, so why not incopy_sep
.Now all functions that call
iter_type_expr
are checking this, butcopy_sep
is usingcopy_type_desc
instead, which explicitly allowsTsubst
, hence the need for a specific assertion.I do not pretend that this alone will make
copy_sep
self-explanatory :-)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we assert = None here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This case actually failed at one test (poly.ml). I am now looking into the bug..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed when the row variable of a polymorphic variant is
Tunivar
.