gno icon indicating copy to clipboard operation
gno copied to clipboard

fix(gnovm): Improve Error Message in `evalStaticTypeOf` function

Open notJoon opened this issue 1 year ago • 2 comments

Description

Closes #1082

Enhanced the error message in evalStaticTypeOf function to match with go's error message and provide more informative feeback.

Example of Errors

Sample code (taken from linked issue)

package main

func main() {
	n := f()
}

func f() {
	println("hello!")
}

Before

panic: evalStaticTypeOf() only supports *CallExpr with 1 result, got ()

After

panic: main/a.gno:3:1: f() (no value) used as value
Hint: Ensure the function returns a single value, or use multiple assignment

Go version (go playground)

./prog.go:4:2: declared and not used: n
./prog.go:4:7: f() (no value) used as value

Further Works

I think it would be good to fix getTypeOf function as well, but I can't think of a case where it would cause panic.

Contributors' checklist...
  • [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
  • [ ] 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, if any. More info here.

notJoon avatar Aug 14 '24 09:08 notJoon

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

:loudspeaker: Thoughts on this report? Let us know!

codecov[bot] avatar Aug 14 '24 09:08 codecov[bot]

@notJoon

Did you get a chance to see @ltzmaxwell's comments? 🙏

zivkovicmilos avatar Oct 02 '24 09:10 zivkovicmilos

what is the status of this one?

ltzmaxwell avatar Nov 06 '24 02:11 ltzmaxwell

what is the status of this one?

@ltzmaxwell dust off now. sorry for the delay 🙏

notJoon avatar Nov 21 '24 07:11 notJoon

Closing this PR in favor of https://github.com/gnolang/gno/pull/3049 to avoid duplicate work

Kouteki avatar Nov 21 '24 09:11 Kouteki