-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[QoI] Check before trying to emit fix-it to convert from array to dictionary #9839
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
Conversation
@swift-ci please smoke test |
@swift-ci please smoke test Linux platform |
@swift-ci please smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise LGTM.
return ["a", 0, "one", 1, "two", 2, "three", 3] | ||
// expected-error@-1 {{contextual type '[String : Any]' cannot be used with array literal}} | ||
// expected-note@-2 {{did you mean to use a dictionary literal instead?}} {{14-15=:}} {{24-25=:}} {{34-35=:}} {{46-47=:}} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Newline please!
lib/Sema/CSDiag.cpp
Outdated
// otherwise it might a structural problem with the expression | ||
// e.g. ["a""b": 1]. | ||
const auto commaLocs = E->getCommaLocs(); | ||
if (numElements % 2 == 0 && commaLocs.size() == numElements - 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're already checking that you have an even number of elements above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right, sorry...
…tionary Before trying to replace every other "," with ":" to help convert from array to dictionary, let's first check if it's appropriate e.g. the number of commas matches the number of elements and number of elements in the array is even which constitutes key/value pairs. Resolves: SR-4952.
@rudkx Thanks, fixes both notes! |
@swift-ci please smoke test and merge |
@swift-ci please smoke test Linux platform |
Ok one more hopefully lucky try, there is an unrelated problem going on with Linux. |
@swift-ci please clean smoke test and merge |
@swift-ci please smoke test Linux platform and merge |
@swift-ci please smoke test Linux platform |
Before trying to replace every other "," with ":" to help convert
from array to dictionary, let's first check if it's appropriate e.g.
the number of commas matches the number of elements and number of
elements in the array is even which constitutes key/value pairs.
Resolves SR-4952.