Skip to content

[Parse] Fixit for inserting 'if' for 'else ... {' all on one line. #18588

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 2 commits into from
Aug 9, 2018

Conversation

huonw
Copy link
Contributor

@huonw huonw commented Aug 9, 2018

This only inserts the fixit when the { is on the same line, e.g.

if foo() {
} else bar() {
}

The thinking being that it's not the right thing for (say) C-style code like

if (foo()) a = 1;
else b = 2;

Fixes rdar://problem/33023297.

@huonw
Copy link
Contributor Author

huonw commented Aug 9, 2018

@swift-ci please smoke test

_ = 42
}
func IfStmt3() {
if 1 > 0 {
} else 1 < 0 { // expected-error {{expected '{' or 'if' after 'else'; did you mean to write 'if'?}}
Copy link
Member

Choose a reason for hiding this comment

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

Mind adding {{9-9= if}}?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, is that the way to test fixits? I assume 9 is the column number?

Copy link
Member

@rintaro rintaro Aug 9, 2018

Choose a reason for hiding this comment

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

Yeah, usually, we don't add FixCode test case for testing fix-its like this. But I think it's OK to add it :)

@huonw huonw force-pushed the fixit-missing-if branch from b748dbb to 91e3406 Compare August 9, 2018 10:03
@huonw
Copy link
Contributor Author

huonw commented Aug 9, 2018

@swift-ci please smoke test

@huonw huonw force-pushed the fixit-missing-if branch from 91e3406 to 75934be Compare August 9, 2018 10:08
@huonw
Copy link
Contributor Author

huonw commented Aug 9, 2018

@swift-ci please smoke test

@huonw huonw merged commit 8c5ff31 into swiftlang:master Aug 9, 2018
@huonw huonw deleted the fixit-missing-if branch August 9, 2018 13:04
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