Skip to content

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

Open
@notJoon

Description

@notJoon

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions