Skip to content

[Sema] Allow TreatArrayLiteralAsDictionary fix to handle literals with more than one element #59277

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

Conversation

LucianoPAlmeida
Copy link
Contributor

This enables recording TreatArrayLiteralAsDictionary for every literal sized array where before only size 1 where recorded which in the cases of the issue reported lead to an unhandled ambiguity.
Also, by allowing the fix to be recorded, if there is a fix for the dictionary being used as array literal this skips recording fixes for mismatching element types as it adds more verbosity and confusion to the diagnostics and the correlation between array literal elements and dictionary key/value can be unclear and skipping this allows the diagnostic to focus on suggesting the use of the correct dictionary literal. I did thought back and fourth for some time with this part, so let me know what you think.
An NFC item is the move of the attempt to repair logic to the fix method attempt.

Resolves #59215.

@LucianoPAlmeida LucianoPAlmeida requested a review from xedin June 6, 2022 02:06
@LucianoPAlmeida
Copy link
Contributor Author

@swift-ci Please test

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.

Looks great, thank you! I think we could also extend this to detect optional-to-optional conversions as well as I mentioned in inline comment.

@LucianoPAlmeida LucianoPAlmeida requested a review from xedin June 7, 2022 04:22
@LucianoPAlmeida
Copy link
Contributor Author

@swift-ci Please test

@LucianoPAlmeida LucianoPAlmeida merged commit c9f1004 into swiftlang:main Jun 7, 2022
@LucianoPAlmeida LucianoPAlmeida deleted the dictionary-array-literals branch June 7, 2022 12:39
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.

[Sema] Unable to produce diagnostic for contextual mismatch in nested dictionary literal
2 participants