Fix Incorrect Location for start_location when token is at start of line #12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
There is an issue with the
Locationwhen the token is at the start of the line.How to reproduce?
Take any file of the https://github.com/SyGuS-Org/benchmarks where the grammar start at the beginning of a new line.
Parse it and run the symbol table builder.
Then checking the
grammar.start_locationshould yield a negative column index.Here is a snippet:
The Fix
Well, we simply distinguish the case when the token is at the beginning of a line.
We check for
pos < 0since in the code when the function is called we take a position and remove 1 so if we are at the start of a line pos is 0 -1 so -1.Why does a minor error like this matter?
Because people can continue to build up on the SyGus specification with the available tools such as using the parser and then modifying the original files with the help of
Location.