Skip to content

Error messages should display the actual package path where the error occurs #4295

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

Open
notJoon opened this issue May 19, 2025 · 2 comments
Open

Comments

@notJoon
Copy link
Member

notJoon commented May 19, 2025

Description

Currently, when type errors or other issues occur in imported packages, the error message only shows the directory name of the package that imported it.

For example, there is a package with a type mismatch:

// PATH: fooo/foo.gno
package fooo

func Foo() int64 {
    return uint64(0) // <- type mismatch
}

If we try to use this package without modification in another package:

// PATH: bar/a.gno
package bar

import (
 "gno.land/p/demo/fooo"
)

func Bar() int64 {
    return foo.Foo()
}
// PATH: bar/a_test.gno
package bar

import (
	"testing"
)

func TestBar(t *testing.T) {
	println(Bar())
}

The following error is displayed:

gno.land/r/demo/bar:4:2: cannot use uint64 as int64 (code=2)
FAIL    examples/gno.land/r/demo/bar  0.01s
FAIL
FAIL: 0 build errors, 1 test errors

This error actually occurs in the fooo package, but the message makes it appear as if the problem is in the bar package, making debugging more difficult.

Therefore, it would be better to modify the error message to indicate the problematic package. I believe this error is likely occurring in the catchRuntimeError function.

@dieudqvarmeta
Copy link

I have fixed this issue
Because I don't know Gnovm test run flow so i can't create the testcase to show the bug has been fixed.
Can you help me check this code or help me create the testcase to test my code?

@notJoon
Copy link
Member Author

notJoon commented May 22, 2025

I have fixed this issue
Because I don't know Gnovm test run flow so i can't create the testcase to show the bug has been fixed.
Can you help me check this code or help me create the testcase to test my code?

In this case, you can use txtar to reproduce it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Triage
Development

No branches or pull requests

2 participants