-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix wrong substitution code #4106
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
Conversation
@@ -863,7 +863,7 @@ pub trait TypeWalk { | |||
&mut |ty, binders| { | |||
if let &mut Ty::Bound(bound) = ty { | |||
if bound.debruijn >= binders { | |||
*ty = substs.0[bound.index].clone(); | |||
*ty = substs.0[bound.index].clone().shift_bound_vars(binders); |
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.
Is there perhaps some way we could make similar wrong code crash on all examples, and not only just on the bad ones?
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.
Like, if this happens to work most of the time, b/c binders is 0
, can we remember a number which tells the nesting/how many times we should shift, and than assert everywhere that nesting levels match?
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.
I don't see how -- if I remember to assert, I can just do it correctly in that place. We could validate types to check that the binders are correct, but that will also only crash if we try to bind to indexes that don't exist.
|
||
#[test] | ||
fn issue_4053_diesel_where_clauses() { | ||
std::env::set_var("CHALK_DEBUG", "1"); |
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.
Should this be removed? It won't be scoped to a single test.
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.
oh, yeah
We need to shift in when we're substituting inside a binder. This should fix rust-lang#4053 (it doesn't fix the occasional overflow that also occurs on the Diesel codebase though).
f5bb062
to
0c01b4e
Compare
bors r+ |
Build succeeded: |
We need to shift in when we're substituting inside a binder.
This should fix #4053 (it doesn't fix the occasional overflow that also occurs on the Diesel codebase though).