Skip to content

[ConstraintSystem] Look through l-value while checking whether dynami… #30040

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
Feb 26, 2020

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Feb 25, 2020

…c key path is recursive

Fix a crash in dynamic member lookup attempting to recursively
lookup a member on the same base type.

The problem is related to isSelfRecursiveKeyPathDynamicMemberLookup
which failed to look through l-value wrapping base type on each side of
the comparison, that's important because it's possible to have l-value
mismatch due to the fact that implicit call always gets l-value base
type but actual subscript which triggered dynamic lookup might be r-value.

Resolves: SR-11743
Resolves: rdar://problem/57091169

…c key path is recursive

Fix a crash in dynamic member lookup attempting to recursively
lookup a member on the same base type.

The problem is related to `isSelfRecursiveKeyPathDynamicMemberLookup`
which failed to look through l-value wrapping base type on each side of
the comparison, that's important because it's possible to have l-value
mismatch due to the fact that implicit call always gets l-value base
type but actual subscript which triggered dynamic lookup might be r-value.

Resolves: [SR-11743](https://bugs.swift.org/browse/SR-11743)
Resolves: rdar://problem/57091169
@xedin xedin requested a review from hborla February 25, 2020 04:34
@xedin
Copy link
Contributor Author

xedin commented Feb 25, 2020

@swift-ci please smoke test

Copy link
Collaborator

@theblixguy theblixguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing my bug! IIRC there are a few dupes of this on JIRA with the same assertion failure.

@xedin
Copy link
Contributor Author

xedin commented Feb 25, 2020

@theblixguy No problem! Would really appreciate if you could help me find the dupes :)

@theblixguy
Copy link
Collaborator

I think one of them is linked to that ticket, I did a quick search but I can't find the dupes, but I do remember seeing a few crashes which were probably related to this. Maybe I was looking at something else. Anyway, I've run into this exact crash many times, so really happy to see it finally being fixed. Here's another test case that you can add (which causes the same crash, but doesn't use protocols or default implementation):

@dynamicMemberLookup
struct Foo {
  let value: Int

  subscript<T>(dynamicMember member: KeyPath<Self, T>) -> T {
    return self[keyPath: member]
  }
}

@xedin
Copy link
Contributor Author

xedin commented Feb 25, 2020

Thank you! We definitely want as many test-cases as possible! :)

@xedin
Copy link
Contributor Author

xedin commented Feb 25, 2020

Hm, looks like GitHub didn't pick up my new commit, I'll give it some time.

@xedin
Copy link
Contributor Author

xedin commented Feb 25, 2020

Ok, here we go.

@xedin
Copy link
Contributor Author

xedin commented Feb 25, 2020

@swift-ci please smoke test

@xedin xedin merged commit 9ae6813 into swiftlang:master Feb 26, 2020
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.

2 participants