-
Notifications
You must be signed in to change notification settings - Fork 388
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
print all errors from scanner.ErrorList
when calling gno.ParseFile
#1933
Labels
🗺️good first issue🗺️
Ideal for newcomer contributors
📦 🤖 gnovm
Issues or PRs gnovm related
🌟 improvement
performance improvements, refactors ...
Comments
thehowl
added
🗺️good first issue🗺️
Ideal for newcomer contributors
📦 🤖 gnovm
Issues or PRs gnovm related
🌟 improvement
performance improvements, refactors ...
labels
Apr 15, 2024
I would Like to work on this 👀 |
7 tasks
thehowl
pushed a commit
that referenced
this issue
May 23, 2024
<!-- please provide a detailed description of the changes made in this pull request. --> This PR aims to print all the errors that are found by the go/parser package. Currently the `parser.ParseFile` function returns an `scanner.ErrorList` object that only prints the first error and a count of the remaining errors. #1933 everything is better explained here. **For the changes this PR introduces**: - Create **issueWithError** function. This function will wrap the lines of code that processed an error (before this PR changes) in order to convert it on an **lintIssue** structure. This existent code applies a regex to localize the parse error more precisely. - The PR changes the behavior of run, test, and lint commands. Not they exit with a non-zero status code as soon as we found some error while parsing the files. This in order to not having the whole stacktrace for some parsing file error, improving visibility. - Add a new case on `gnovm/cmd/gno/lint.go.catchRuntimeError` to handle and print all errors of an error with type `scanner.ErrorList` - remove some wrapping during panic calls. This was done by simplicity some of the calls were doing `panic(errors.Wrap(err, "parsing file "+mfile.Name))` here err has the type scanner.ErrorList but as we're wrapping it it would be more complex and difficult to read on **catchRuntimeError** to identify an error with the type ErrorList **Results:** (Using issue example) - lint: ```cmd -- NOW ./.: missing 'gno.mod' file (code=1). test.gno:6: expected ';', found example (code=2). test.gno:7: expected '}', found 'EOF' (code=2). exit status 1 ---- BEFORE ./.: missing 'gno.mod' file (code=1). test.gno:6: expected ';', found example (and 1 more errors) (code=2). ``` - run: ```cmd -- NOW test.gno:6: expected ';', found example (code=2). test.gno:7: expected '}', found 'EOF' (code=2). exit status 1 ---- BEFORE panic: test.gno:6:5: expected ';', found example (and 1 more errors) goroutine 1 [running]: github.com/gnolang/gno/gnovm/pkg/gnolang.MustReadFile(...) /Users/miguel/gnorigin/gnovm/pkg/gnolang/go2gno.go:49 main.parseFiles({0x140003b1720, 0x1, 0x1400031fb48?}) /Users/miguel/gnorigin/gnovm/cmd/gno/run.go:132 +0x27c main.parseFiles({0x140003b09a0, 0x1, 0x0?}) /Users/miguel/gnorigin/gnovm/cmd/gno/run.go:121 +0x158 main.execRun(0x14000373230, {0x140003b09a0, 0x1, 0x1}, {0x100ca3e68, 0x140003b3bd0}) /Users/miguel/gnorigin/gnovm/cmd/gno/run.go:89 +0x174 main.newRunCmd.func1({0x0?, 0x1400019c140?}, {0x140003b09a0?, 0x0?, 0x0?}) /Users/miguel/gnorigin/gnovm/cmd/gno/run.go:35 +0x3c github.com/gnolang/gno/tm2/pkg/commands.(*Command).Run(0x1400031fdc8?, {0x100c9af18?, 0x101249700?}) /Users/miguel/gnorigin/tm2/pkg/commands/command.go:247 +0x17c github.com/gnolang/gno/tm2/pkg/commands.(*Command).Run(0x140003ae2c0?, {0x100c9af18?, 0x101249700?}) /Users/miguel/gnorigin/tm2/pkg/commands/command.go:251 +0x12c github.com/gnolang/gno/tm2/pkg/commands.(*Command).ParseAndRun(0x140003ae6e0?, {0x100c9af18, 0x101249700}, {0x1400019c130?, 0x140003ae790?, 0x140003ae840?}) /Users/miguel/gnorigin/tm2/pkg/commands/command.go:132 +0x4c github.com/gnolang/gno/tm2/pkg/commands.(*Command).Execute(0x100ca3e68?, {0x100c9af18?, 0x101249700?}, {0x1400019c130?, 0x1011a5ef8?, 0x140000021a0?}) /Users/miguel/gnorigin/tm2/pkg/commands/command.go:114 +0x28 main.main() /Users/miguel/gnorigin/gnovm/cmd/gno/main.go:13 +0x6c ``` <details><summary>Contributors' checklist...</summary> - [ ] 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 - [ ] 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>
github-project-automation
bot
moved this from Backlog
to Done
in 🧙♂️gno.land core team
Jun 28, 2024
Closed by #2011 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
🗺️good first issue🗺️
Ideal for newcomer contributors
📦 🤖 gnovm
Issues or PRs gnovm related
🌟 improvement
performance improvements, refactors ...
h/t @gfanton
Currently, errors from a
scanner.ErrorList
are printed directly, and so only the first error is shown:We should handle the cases where we have a scanner.ErrorList and print all errors available in the list
The text was updated successfully, but these errors were encountered: