-
Notifications
You must be signed in to change notification settings - Fork 83
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
Track existentials in constrain_type_jkind #3686
base: main
Are you sure you want to change the base?
Conversation
9cad1f3
to
0ccba98
Compare
7c3bfe6
to
d463992
Compare
In the long run, I think it would be better if we could inject kinds back into the space of types used for with-kinds. That would give more precise with-kinds here. Alternatively, with-kinds could bind type variables, but that seems worse to me.
I think that probably the right solution here is to leave apply as it is and use: let apply ty2 existentials =
apply env (decl.type_params @ existentials) ty2 (args @ existentials)
in in |
Yes that seems simpler. Thanks for taking a look. I will try. |
I just pushed a new implementation of how we track bound variables. The old one did a lot of building of sets, etc., which were almost never consulted. I also considered just tracking a list of I have not done perf testing here, but this just has to be better than what I wrote before. |
The first commit shows the bad case, the second commit adds some helpful debugging support, and the third commit fixes the problem.
A few notes:
awk
invocation. The alternative is to define this function in the compiler, but dependencies within the Btype module make this slightly annoying. Writing one very long line seemed the best option, unless you (for any value of "you") want to improve thatawk
invocation.constrain_type_jkind
(this is pretty straightforward, in the end), and 2) round up with-bounds inupdate_decl_jkind
. Step 2 surprised me, but is clearly the right thing to do. Before this patch, we hadtype_jkind
s in the wild with unbound variables in them. Horrors.apply
step inunbox_once
copies the unboxed type's field, which means that the variable changes identity. I worked around this by including the existentials within the same copy scope, but this makes me very sad. Either the copy mechanism should be taught not to copy existentials at generic-level (which seems hard and probably wrong), or maybe some cleverer interaction with thecopy_scope
could simplify this. Staring at this a bit showed no obvious way to get what I want, but I'm still a little mystefied by e.g.Tsubst
. I'm confident that what I did is correct, but not confident that it's as good as it could be (from both a coding clarity and performance standpoint). Very happy for pointers here, probably from @lpw25 or @stedolan.Review: @ccasin