-
-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
avoid using sign.Results.Closing when it's invalid
The position may be token.NoPos, an invalid position, if there's a single result parameter without parentheses. Using token.FileSet.Offset on token.NoPos+1 would panic: panic: invalid Pos value 1 (should be in [774665, 781950]) We didn't catch this because our tests always start with an empty token.FileSet, so most of our files start with the base position 1. A user ran into the bug when formatting many files at once. To ensure we catch these bugs quicker in the future, insert a dummy ten-byte file to every new FileSet we create. Finally, add a test, which reproduces the panic thanks to the dummy base file mentioned above. Fixes #166.
- Loading branch information
Showing
3 changed files
with
33 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters