Skip to content
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

cryptic error: v := f(), when f returns no values, panics with evalStaticTypeOf() only supports *CallExpr with 1 result #1082

Open
thehowl opened this issue Aug 30, 2023 · 0 comments · May be fixed by #2695
Labels
🐞 bug Something isn't working 🌟 must have 🌟 Mandatory work needed to complete a project 📦 🤖 gnovm Issues or PRs gnovm related 🌟 improvement performance improvements, refactors ...

Comments

@thehowl
Copy link
Member

thehowl commented Aug 30, 2023

Minimal example to reproduce:

package main

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

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

The resulting panic is the following:

panic: evalStaticTypeOf() only supports *CallExpr with 1 result, got () [recovered]
        panic: main/a.gno:4: evalStaticTypeOf() only supports *CallExpr with 1 result, got ()

goroutine 1 [running]:
github.com/gnolang/gno/gnovm/pkg/gnolang.Preprocess.func2.1()
        /home/howl/oc/gno/gnovm/pkg/gnolang/preprocess.go:173 +0x46d
panic({0xbf0b00, 0xc00007d450})
        /usr/lib/go/src/runtime/panic.go:890 +0x263
github.com/gnolang/gno/gnovm/pkg/gnolang.evalStaticTypeOf({0xf651b0?, 0xc000188240?}, {0xf62ed8?, 0xc000501800?}, {0xf5c408?, 0xc000128a20?})
        /home/howl/oc/gno/gnovm/pkg/gnolang/preprocess.go:2020 +0xc5
github.com/gnolang/gno/gnovm/pkg/gnolang.Preprocess.func2({0xc00025ae00?, 0x2, 0x20}, 0x46, 0xc000254524?, {0xf5aaf0, 0xc000128a80?}, 0x3)
        /home/howl/oc/gno/gnovm/pkg/gnolang/preprocess.go:1554 +0x8688
github.com/gnolang/gno/gnovm/pkg/gnolang.transcribe(0xc000131970, {0xc00025ae00?, 0x2, 0x20}, 0x46, 0xf5b170?, {0xf5aaf0?, 0xc000128a80}, 0xc000131447)
        /home/howl/oc/gno/gnovm/pkg/gnolang/transcribe.go:728 +0x4b63
github.com/gnolang/gno/gnovm/pkg/gnolang.transcribe(0xc000131970, {0xc00025ae00?, 0x1, 0x20}, 0x4d, 0xf5b0a0?, {0xf5b170?, 0xc000501800}, 0xc000131677)
        /home/howl/oc/gno/gnovm/pkg/gnolang/transcribe.go:670 +0x5125
github.com/gnolang/gno/gnovm/pkg/gnolang.transcribe(0xc000131970, {0xc00025ae00?, 0x0, 0x20}, 0x0, 0x200?, {0xf5b0a0?, 0xc0002b3b80}, 0xc0001318a7)
        /home/howl/oc/gno/gnovm/pkg/gnolang/transcribe.go:708 +0x4cf3
github.com/gnolang/gno/gnovm/pkg/gnolang.Transcribe({0xf5b0a0?, 0xc0002b3b80}, 0x7ffe8a9f6e65?)
        /home/howl/oc/gno/gnovm/pkg/gnolang/transcribe.go:133 +0xbe
github.com/gnolang/gno/gnovm/pkg/gnolang.Preprocess({0xf651b0, 0xc000188240}, {0xf632d8, 0xc0000ca580}, {0xf5b0a0?, 0xc0002b3b80?})
        /home/howl/oc/gno/gnovm/pkg/gnolang/preprocess.go:149 +0x277
github.com/gnolang/gno/gnovm/pkg/gnolang.(*Machine).runFiles(0xc0000c4fc0, {0xc0000123e8, 0x1, 0x1})
        /home/howl/oc/gno/gnovm/pkg/gnolang/machine.go:520 +0x34e
github.com/gnolang/gno/gnovm/pkg/gnolang.(*Machine).RunFiles(...)

This is not such a weird mistake to do when programming in Go/Gno, so a panic like this with no reference to the incriminated code is hardly helpful to the developer.

(Part of a series of issues encountered while developing gnochess)

@thehowl thehowl added 📦 🤖 gnovm Issues or PRs gnovm related 🌟 improvement performance improvements, refactors ... labels Aug 30, 2023
@moul moul added this to the 🚀 main.gno.land milestone Sep 6, 2023
@moul moul added the 🐞 bug Something isn't working label Oct 27, 2023
@notJoon notJoon linked a pull request Aug 14, 2024 that will close this issue
7 tasks
@zivkovicmilos zivkovicmilos added the 🌟 must have 🌟 Mandatory work needed to complete a project label Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working 🌟 must have 🌟 Mandatory work needed to complete a project 📦 🤖 gnovm Issues or PRs gnovm related 🌟 improvement performance improvements, refactors ...
Projects
Development

Successfully merging a pull request may close this issue.

3 participants