Skip to content

[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

Merged
merged 1 commit into from
May 23, 2017

Conversation

xedin
Copy link
Contributor

@xedin xedin commented May 22, 2017

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.

@xedin xedin requested a review from rudkx May 22, 2017 20:20
@xedin
Copy link
Contributor Author

xedin commented May 22, 2017

@swift-ci please smoke test

@xedin
Copy link
Contributor Author

xedin commented May 22, 2017

@swift-ci please smoke test Linux platform

@xedin xedin changed the title [QoI] Before trying to emit fix-it to convert from array to dictionary [QoI] Check before trying to emit fix-it to convert from array to dictionary May 22, 2017
@xedin
Copy link
Contributor Author

xedin commented May 22, 2017

@swift-ci please smoke test

Copy link
Contributor

@rudkx rudkx left a 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=:}}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Newline please!

// 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) {
Copy link
Contributor

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.

Copy link
Contributor Author

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.
@xedin
Copy link
Contributor Author

xedin commented May 23, 2017

@rudkx Thanks, fixes both notes!

@xedin
Copy link
Contributor Author

xedin commented May 23, 2017

@swift-ci please smoke test and merge

@xedin
Copy link
Contributor Author

xedin commented May 23, 2017

@swift-ci please smoke test Linux platform

@xedin
Copy link
Contributor Author

xedin commented May 23, 2017

Ok one more hopefully lucky try, there is an unrelated problem going on with Linux.

@xedin
Copy link
Contributor Author

xedin commented May 23, 2017

@swift-ci please clean smoke test and merge

@xedin
Copy link
Contributor Author

xedin commented May 23, 2017

@swift-ci please smoke test Linux platform and merge

@xedin
Copy link
Contributor Author

xedin commented May 23, 2017

@swift-ci please smoke test Linux platform

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