-
Notifications
You must be signed in to change notification settings - Fork 373
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(sdk/vm): improve MsgCall panic error message for wrong number of args #1610
fix(sdk/vm): improve MsgCall panic error message for wrong number of args #1610
Conversation
…mber of arguments Signed-off-by: Jeff Thompson <[email protected]>
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.
greatly appreciated!
I think we can be more explicit about how many args we want, so here is a better version imo.
(note: I wondered what happened if we had a variadic function; turns out we don't support these in maketx call currently, though it would be nice if we did :) going to make an issue)
Looks good. I clicked "Add suggestion to batch".
You probably saw that this check for the number of arguments comes just after excluding variadics. gno/gno.land/pkg/sdk/vm/keeper.go Line 241 in 12b4b45
|
Co-authored-by: Morgan <[email protected]>
Signed-off-by: Jeff Thompson <[email protected]>
I also updated the test to use the revised expected panic message. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1610 +/- ##
==========================================
+ Coverage 55.79% 56.05% +0.26%
==========================================
Files 436 438 +2
Lines 66168 66720 +552
==========================================
+ Hits 36917 37400 +483
- Misses 26360 26420 +60
- Partials 2891 2900 +9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
…args (gnolang#1610) If a realm function Call has too many arguments, VMKeeper Call panics with an uninformative index error message like "index out of range [1] with length 1" when it is [checking the arguments](https://github.com/gnolang/gno/blob/12b4b458e1b13d491a5797aa11b2002242f012bd/gno.land/pkg/sdk/vm/keeper.go#L244). One of our devs lost time trying to figure this out, as would other devs presumably. This PR adds explicit checks for number of arguments with informative panic messages like "not enough arguments in call to Echo" or "too many arguments in call to Echo" . (These are the same errors as the Go compiler.) (I couldn't find an existing issue for this. If you already have other plans to improve this error message, then you can close this PR.) <details><summary>Contributors' checklist...</summary> - [x] Added new tests, or not needed, or not feasible - [x] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [x] Updated the official documentation not needed - [x] 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> --------- Signed-off-by: Jeff Thompson <[email protected]> Co-authored-by: Morgan <[email protected]>
If a realm function Call has too many arguments, VMKeeper Call panics with an uninformative index error message like "index out of range [1] with length 1" when it is checking the arguments. One of our devs lost time trying to figure this out, as would other devs presumably.
This PR adds explicit checks for number of arguments with informative panic messages like "not enough arguments in call to Echo" or "too many arguments in call to Echo" . (These are the same errors as the Go compiler.)
(I couldn't find an existing issue for this. If you already have other plans to improve this error message, then you can close this PR.)
Contributors' checklist...
BREAKING CHANGE: xxx
message was included in the description