Skip to content

Prevent unreachable when file ends with struct field #2824

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
Jul 6, 2019

Conversation

hryx
Copy link
Contributor

@hryx hryx commented Jul 5, 2019

Fixes #2813

To demystify the original example program which triggers the problem:

_

This is grammatically valid and means "top-level struct field with no type or default value defined".

ContainerField <- IDENTIFIER (COLON TypeExpr)? (EQUAL Expr)?

This behavior was also triggered with the new test case:

a: bool

The renderer incorrectly assumed the number of remaining tokens in the file after the field.

@andrewrk andrewrk merged commit 7f61818 into ziglang:master Jul 6, 2019
@andrewrk
Copy link
Member

andrewrk commented Jul 6, 2019

Thanks! Related issue: #2022

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.

zig fmt hits unreachable on tiny file
2 participants