Skip to content

Proper source locations for parser errors.#4104

Merged
axic merged 2 commits intodevelopfrom
parserErrorSourceLocations
May 9, 2018
Merged

Proper source locations for parser errors.#4104
axic merged 2 commits intodevelopfrom
parserErrorSourceLocations

Conversation

@ekpyron
Copy link
Copy Markdown
Collaborator

@ekpyron ekpyron commented May 9, 2018

Closes #3874.

It may be good to merge this quickly, since all future parser tests will be affected.

@ekpyron ekpyron self-assigned this May 9, 2018
@ekpyron ekpyron requested review from axic and chriseth May 9, 2018 11:17
erak
erak previously approved these changes May 9, 2018
Copy link
Copy Markdown
Collaborator

@erak erak left a comment

Choose a reason for hiding this comment

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

Could this be a bit more specific? Something like: "Use the tokens entire location in case of a parser error."
Otherwise it's looks good!

@ekpyron ekpyron force-pushed the parserErrorSourceLocations branch from 7f9479a to 305fc06 Compare May 9, 2018 12:08
@ekpyron
Copy link
Copy Markdown
Collaborator Author

ekpyron commented May 9, 2018

@bit-shift What about now?

Copy link
Copy Markdown
Collaborator

@erak erak left a comment

Choose a reason for hiding this comment

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

Looks good :)

}
// ----
// ParserError: (25-25): enum with no members is not allowed.
// ParserError: (25-26): enum with no members is not allowed.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This seems to be short. emit foo { } seems to be longer than 2 characters.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The source location of the error is the whole parser token at which the error is recognized. In this case this is only the closing bracket. enum foo { is still valid - only at the following } the parser can recognize that the enum is empty, so that's the reported error location.

I split this PR into two commits - the first one is the code changes and the second one is the update of the tests. If you compile only the first commit and run isoltest, it will mark all the source locations that are updated in red, so this way it is easy to inspect all new source locations.

One may argue that the location here should be enum foo { } entirely, but this would require major changes in parserError, resp. fatalParserError (they would have to be supplied with the source location as arguments, instead of merely using the location of the current token).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am not saying there's a bug in the changes of the PR, but rather an issue to be fixed in general.

@axic axic merged commit 2c3f57b into develop May 9, 2018
@axic axic deleted the parserErrorSourceLocations branch May 9, 2018 13:06
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.

3 participants