Skip to content

[Sema] Correctly diagnose passing tuple as only argument to function with multiple parameters #36499

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
Mar 19, 2021

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Mar 18, 2021

If a tuple is passed as the only argument to a function that takes two unnamed arguments, we try to diagnose the missing argument label. However, in the old diagnose code we didn’t distinguish between non-existing arguments and arguments without labels; both behaved the same.

Thus, the missing second argument in the function call would line up with the empty second argument label, not producing a diagnostic, but hitting an assertion later on.

Distinguish between the two to fix the issue.

Fixes rdar://64319340 [SR-13002]

@ahoppen ahoppen requested a review from hborla March 18, 2021 18:14
@ahoppen
Copy link
Member Author

ahoppen commented Mar 18, 2021

@swift-ci Please smoke test

@xedin
Copy link
Contributor

xedin commented Mar 18, 2021

I think this is good to avoid a crash but we should also look into using a tailored fix for tuple splat here instead of combination of re-label + synthesize.

…with multiple parameters

If a tuple is passed as the only argument to a function that takes two unnamed arguments, we try to diagnose the missing argument label. However, in the old diagnose code we didn’t distinguish between non-existing arguments and arguments without labels; both behaved the same.

Thus, the missing second argument in the function call would line up with the empty second argument label, not producing a diagnostic, but hitting an assertion later on.

Distinguish between the two to fix the issue.

Fixes rdar://64319340
@ahoppen
Copy link
Member Author

ahoppen commented Mar 19, 2021

Updated a few test cases that were previously actually producing incorrect diagnostics (because they were omitting unnamed arguments in the message).

@swift-ci Please smoke test

@xedin
Copy link
Contributor

xedin commented Mar 19, 2021

Thank you!

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