-
Notifications
You must be signed in to change notification settings - Fork 382
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
fix: unify the precompile output to make it easier to parse and read. #1670
fix: unify the precompile output to make it easier to parse and read. #1670
Conversation
so `file.gno:line:coumn` is accessible immediately and can be printed.
Previous shifting had LSP consideration in mind, and LSP position in document is zero-based, which shouldn't affect the output of `precompile` command.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #1670 +/- ##
==========================================
+ Coverage 53.34% 56.10% +2.76%
==========================================
Files 480 447 -33
Lines 72597 66739 -5858
==========================================
- Hits 38725 37446 -1279
+ Misses 30865 26374 -4491
+ Partials 3007 2919 -88
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏
Tagging @gfanton for second review/merge as he's worked on gno lint too |
PR gnolang#1670 updated the `gno precompile` output, by translating the errors reported from generated go files into their related gno files. This was done by shifting the line number, because generated go files have an extra header of 4 lines. @thehowl found a better way to do this, by using the `//line` directive. By adding this directive at the end of this extra header we have in generated go files, the go compiler will skip it and will output file position that corresponds exactly to the gno file position. This allows the removal of the line shifting mentionned above. See https://pkg.go.dev/cmd/compile#hdr-Compiler_Directives
PR gnolang#1670 updated the `gno precompile` output by translating errors reported by generated go files into their corresponding gno files. This was done by shifting the line number, since generated go files have an extra header of 4 lines. @thehowl found a better way to do this by using the //line directive. By adding this directive at the end of this extra header we have in generated go files, the go compiler will skip it and output a file position that exactly matches the gno file position. This eliminates the need for the line shifting mentioned above. See https://pkg.go.dev/cmd/compile#hdr-Compiler_Directives
PR #1670 updated the `gno precompile` output by translating errors reported by generated go files into their corresponding gno files. This was done by shifting the line number, since generated go files have an extra header of 4 lines. @thehowl found a better way to do this by using the //line directive. By adding this directive at the end of this extra header we have in generated go files, the go compiler will skip it and output a file position that exactly matches the gno file position. This eliminates the need for the line shifting mentioned above. See https://pkg.go.dev/cmd/compile#hdr-Compiler_Directives <!-- please provide a detailed description of the changes made in this pull request. --> <details><summary>Contributors' checklist...</summary> - [x] Added new tests, or not needed, or not feasible - [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [ ] Updated the official documentation or not needed - [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [x] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests - [ ] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md). </details>
…gnolang#1670) <!-- please provide a detailed description of the changes made in this pull request. --> Fix gnolang#1636 Under the hood, use `scanner.ErrorList` from the stdlib all the way to store all errors with the filename and the position in the file. Note that kind of error is already returned by `parser.ParserFile`. For the `go build` output, instead of printing it like it is, parse it and shift it to represent the related gno file. Run the tests: ``` $ go test ./gnovm/cmd/gno -v -run Test_ScriptsPrecompile ``` <details><summary>Contributors' checklist...</summary> - [x] Added new tests, or not needed, or not feasible - [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [ ] Updated the official documentation or not needed - [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [x] Added references to related issues and PRs - [x] Provided any useful hints for running manual tests - [ ] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md). </details>
…ng#1688) PR gnolang#1670 updated the `gno precompile` output by translating errors reported by generated go files into their corresponding gno files. This was done by shifting the line number, since generated go files have an extra header of 4 lines. @thehowl found a better way to do this by using the //line directive. By adding this directive at the end of this extra header we have in generated go files, the go compiler will skip it and output a file position that exactly matches the gno file position. This eliminates the need for the line shifting mentioned above. See https://pkg.go.dev/cmd/compile#hdr-Compiler_Directives <!-- please provide a detailed description of the changes made in this pull request. --> <details><summary>Contributors' checklist...</summary> - [x] Added new tests, or not needed, or not feasible - [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [ ] Updated the official documentation or not needed - [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [x] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests - [ ] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md). </details>
Fix #1636
Under the hood, use
scanner.ErrorList
from the stdlib all the way to store all errors with the filename and the position in the file. Note that kind of error is already returned byparser.ParserFile
.For the
go build
output, instead of printing it like it is, parse it and shift it to represent the related gno file.Run the tests:
Contributors' checklist...
BREAKING CHANGE: xxx
message was included in the description