Skip to content
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

[SR-165][Parser] Fix diagnosis location for missing while after repeat body #754

Merged
merged 1 commit into from Jan 16, 2016

Conversation

gregomni
Copy link
Collaborator

Also cleaned up unnecessary body.isNonNull() check here. The code just above already constructs a synthetic empty brace stmt for the body if it didn’t have a real one.

if (body.isNonNull())
return body;
return makeParserError();
diagnose(body.getPtrOrNull()->getEndLoc(), diag::expected_while_after_repeat_body);
Copy link
Member

Choose a reason for hiding this comment

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

The previous code was careful to handle the "null" case for "body", while this code will crash if "body" is null.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@DougGregor Yep, but look up a couple lines. There's already a check for body.isNull() which creates a synthetic body (lines 1804-1806), so body can never be null here. statements.swift:269 tests exactly this case.

Also cleaned up unnecessary body.isNonNull() check here. The code just
above already constructs a synthetic empty brace stmt for the body if
it didn’t have a real one.
@gregomni
Copy link
Collaborator Author

(Rebased and merged to fix conflict -- just a new expected warning got added near the test added in this pull.)

@lattner
Copy link
Collaborator

lattner commented Jan 16, 2016

Doug, I agree with @gregomni Patch looks good to me, thanks!

lattner added a commit that referenced this pull request Jan 16, 2016
[SR-165][Parser] Fix diagnosis location for missing while after repeat body
@lattner lattner merged commit a39be46 into apple:master Jan 16, 2016
@gregomni gregomni deleted the sr-165 branch January 16, 2016 06:25
MaxDesiatov pushed a commit to MaxDesiatov/swift that referenced this pull request May 1, 2020
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.

None yet

3 participants