Skip to content

[ConstraintSystem] Fix non-determinism in diagnoseAmbiguity #39751

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

Merged
merged 2 commits into from
Oct 15, 2021

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Oct 14, 2021

Simplification of member locator would produce a base expression,
this is what we want for diagnostics but not for comparisons in
diagnoseAmbiguity because base expression is located at a different
depth which would lead to incorrect results if both reference and base
expression are ambiguous e.g. test[x].count if both [x] and count
are ambiguous than simplification of count would produce [x] which
is incorrect.

This is the test-case (already in the suite) that exibits this behavior:

func test_ambiguity_with_placeholders(pairs: [(rank: Int, count: Int)]) -> Bool {
  return pairs[<#^ARG^#>].count == 2
}

Here subscript would either return a tuple or ArraySlice and
count is ambiguous because both have it.

xedin added 2 commits October 14, 2021 11:26
Simplification of member locator would produce a base expression,
this is what we want for diagnostics but not for comparisons in
`diagnoseAmbiguity` because base expression is located at a different
depth which would lead to incorrect results if both reference and base
expression are ambiguous e.g. `test[x].count` if both `[x]` and `count`
are ambiguous than simplification of `count` would produce `[x]` which
is incorrect.

This is the test-case (already in the suite) that exibits this behavior:

```
func test_ambiguity_with_placeholders(pairs: [(rank: Int, count: Int)]) -> Bool {
  return pairs[<#^ARG^#>].count == 2
}
```

Here subscript would either return a tuple or `ArraySlice` and
`count` is ambiguous because both have it.
@xedin
Copy link
Contributor Author

xedin commented Oct 14, 2021

@swift-ci please smoke test

@xedin xedin merged commit cbb69ce into swiftlang:main Oct 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant