-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[ConstraintGraph] Disallow subtype constraint contractions #11855
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
2f1330e
to
ac311a0
Compare
@swift-ci please smoke 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.
Otherwise LGTM.
$0.b = 0 | ||
} | ||
|
||
print(rdar34333874) |
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.
newline
} | ||
|
||
let rdar34333874 = foo(C()) { | ||
$0.a = 42 |
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 this really testing the same thing as the reported bug? This actually is mutating the input whereas the bug report wasn't.
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.
Example from the rdar does modify fields of $0
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.
The actual original code did mutate input inside the closure. I'd suggest testing both cases to be on the safe side.
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.
Sure, sounds good, I'll add one which doesn't mutate the fields.
// RUN: rm -rf %t | ||
// RUN: mkdir -p %t | ||
// RUN: %target-build-swift %s -o %t/a.out | ||
// RUN: %target-run %t/a.out |
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.
Drive-by comment: This should be %target-run-simple-swift
, which gets run in more situations.
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.
Thanks, @jrose-apple ! I didn't know that existed...
ac311a0
to
f7960bc
Compare
@swift-ci please smoke test |
return this | ||
} | ||
|
||
let rdar34333874 = foo(C()) { |
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.
Hmm, apparently I didn't submit my comment about the test. Are you sure this is testing the same thing as the original report? This appears to actually be mutating something whereas the original report wasn't.
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.
Presently subtype constraint is considered a candidate for contraction via `shouldContractEdge` when left-hand side of the subtype constraint is an inout type with type variable inside. Although it's intended to be used only in combination with BindParam constraint assigned to the same variable, that is actually never checked and contraction of subtype constraint like that is invalid. Resolves: rdar://problem/34333874
f7960bc
to
0a178fd
Compare
I've fixed a problem in |
@swift-ci please smoke test |
@swift-ci please test source compatibility |
Presently subtype constraint is considered a candidate for contraction
via
shouldContractEdge
when left-hand side of the subtype constraintis an inout type with type variable inside. Although it's intended to
be used only in combination with BindParam constraint assigned to the
same variable, that is actually never checked and contraction of subtype
constraint like that is invalid.
Resolves: rdar://problem/34333874