Skip to content

[CS] Fix a crash in AllowArgumentMismatch #32356

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 1 commit into from
Jun 13, 2020
Merged

[CS] Fix a crash in AllowArgumentMismatch #32356

merged 1 commit into from
Jun 13, 2020

Conversation

theblixguy
Copy link
Collaborator

@theblixguy theblixguy commented Jun 12, 2020

The compiler was crashing because AllowArgumentMismatch relies on getFunctionArgApplyInfo() returning a non-optional FunctionArgApplyInfo value, which we failed to provide in a situation when simplifyLocator couldn't simplify a locator where a TypeExpr was provided as a subscript argument.

Resolves SR-12990
Resolves rdar://problem/64303153

@theblixguy theblixguy requested a review from xedin June 12, 2020 19:25
Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

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

I think we have it setup this way on purpose, AllowArgumentMismatch should only be attached to the argument-to-parameter conversion failures and getFunctionArgApplyInfo should be able to extract information based on that locator. Why does it fail in this case?

@theblixguy
Copy link
Collaborator Author

theblixguy commented Jun 12, 2020

@xedin Oh sorry, I didn't realise it was intentional. In that case, I think it might be better to fix simplifyLocator because we have a locator like apply argument -> comparing call argument #0 to parameter #0 and when we simplify ApplyArgument we get a TypeExpr anchor and when we try to simplify ApplyArgToParam we don't handle a TypeExpr and so simplifyLocatorToAnchor returns nullptr (due to path being non-empty).

@xedin
Copy link
Contributor

xedin commented Jun 12, 2020

@theblixguy Right, that's what I expected, I think we need to adjust logic in simplifyLocatorToAnchor to handle cases we overlooked...

@theblixguy
Copy link
Collaborator Author

@xedin Sounds good, that's what I have done now!

…e the index expression isn't a tuple or paren expression
Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

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

Thank you!

@xedin
Copy link
Contributor

xedin commented Jun 13, 2020

@swift-ci please smoke test

@xedin
Copy link
Contributor

xedin commented Jun 13, 2020

@theblixguy Could you open a PR for 5.3? You'd have to adjust isExpr to isa I think.

@theblixguy
Copy link
Collaborator Author

Sure, here's the 5.3 PR: #32361

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.

3 participants