diff --git a/gnovm/cmd/gno/testdata/gno_test/lint_bad_import.txtar b/gnovm/cmd/gno/testdata/gno_test/lint_bad_import.txtar index 946e1bcba35..fc4039d38c6 100644 --- a/gnovm/cmd/gno/testdata/gno_test/lint_bad_import.txtar +++ b/gnovm/cmd/gno/testdata/gno_test/lint_bad_import.txtar @@ -16,4 +16,4 @@ func main() { -- stdout.golden -- -- stderr.golden -- -bad_file.gno:1: unknown import path python (code=2). +bad_file.gno:3: unknown import path python (code=2). diff --git a/gnovm/cmd/gno/testdata/gno_test/test_with-native-fallback.txtar b/gnovm/cmd/gno/testdata/gno_test/test_with-native-fallback.txtar index 42dae650a7e..5b807442abc 100644 --- a/gnovm/cmd/gno/testdata/gno_test/test_with-native-fallback.txtar +++ b/gnovm/cmd/gno/testdata/gno_test/test_with-native-fallback.txtar @@ -4,7 +4,7 @@ ! stdout .+ stderr 'panic: unknown import path net \[recovered\]' -stderr ' panic: gno.land/r/\w{8}/contract.gno:1: unknown import path net' +stderr ' panic: gno.land/r/\w{8}/contract.gno:3: unknown import path net' gno test -v --with-native-fallback . diff --git a/gnovm/cmd/gno/testdata/gno_test/unknow_lib.txtar b/gnovm/cmd/gno/testdata/gno_test/unknow_lib.txtar index 33fc85fd35f..3df7ab254e4 100644 --- a/gnovm/cmd/gno/testdata/gno_test/unknow_lib.txtar +++ b/gnovm/cmd/gno/testdata/gno_test/unknow_lib.txtar @@ -4,13 +4,13 @@ ! stdout .+ stderr 'panic: unknown import path foobarbaz \[recovered\]' -stderr ' panic: gno.land/r/\w{8}/contract.gno:1: unknown import path foobarbaz' +stderr ' panic: gno.land/r/\w{8}/contract.gno:3: unknown import path foobarbaz' ! gno test -v --with-native-fallback . ! stdout .+ stderr 'panic: unknown import path foobarbaz \[recovered\]' -stderr ' panic: gno.land/r/\w{8}/contract.gno:1: unknown import path foobarbaz' +stderr ' panic: gno.land/r/\w{8}/contract.gno:3: unknown import path foobarbaz' -- contract.gno -- package contract diff --git a/gnovm/pkg/gnolang/debugger_test.go b/gnovm/pkg/gnolang/debugger_test.go index ad78cb143ee..1b5a72a183a 100644 --- a/gnovm/pkg/gnolang/debugger_test.go +++ b/gnovm/pkg/gnolang/debugger_test.go @@ -117,14 +117,14 @@ func TestDebug(t *testing.T) { {in: "p 'a'\n", out: "(97 int32)"}, {in: "p '界'\n", out: "(30028 int32)"}, {in: "p \"xxxx\"\n", out: `("xxxx" string)`}, - {in: "si\n", out: "sample.gno:4"}, - {in: "s\ns\n", out: "=> 33: num := 5"}, + {in: "si\n", out: "sample.gno:14"}, + {in: "s\ns\n", out: `=> 14: var global = "test"`}, {in: "s\n\n", out: "=> 33: num := 5"}, {in: "foo", out: "command not available: foo"}, {in: "\n\n", out: "dbg> "}, {in: "#\n", out: "dbg> "}, {in: "p foo", out: "Command failed: could not find symbol value for foo"}, - {in: "b +7\nc\n", out: "=> 11:"}, + {in: "b +7\nc\n", out: "=> 21: r := t.A[i]"}, {in: brk + "clear 0\n", out: "dbg> "}, {in: brk + "clear -1\n", out: "Command failed: invalid breakpoint id: -1"}, {in: brk + "clear\n", out: "dbg> "}, diff --git a/gnovm/pkg/gnolang/go2gno.go b/gnovm/pkg/gnolang/go2gno.go index 5c74621c973..4ae65211231 100644 --- a/gnovm/pkg/gnolang/go2gno.go +++ b/gnovm/pkg/gnolang/go2gno.go @@ -767,6 +767,7 @@ func toDecls(fs *token.FileSet, gd *ast.GenDecl) (ds Decls) { Const: true, } cd.SetAttribute(ATTR_IOTA, si) + setLoc(fs, s.Pos(), cd) ds = append(ds, cd) } else { var names []NameExpr @@ -785,6 +786,7 @@ func toDecls(fs *token.FileSet, gd *ast.GenDecl) (ds Decls) { Values: values, Const: false, } + setLoc(fs, s.Pos(), vd) ds = append(ds, vd) } case *ast.ImportSpec: @@ -792,16 +794,19 @@ func toDecls(fs *token.FileSet, gd *ast.GenDecl) (ds Decls) { if err != nil { panic("unexpected import spec path type") } - ds = append(ds, &ImportDecl{ + im := &ImportDecl{ NameExpr: *Nx(toName(s.Name)), PkgPath: path, - }) + } + setLoc(fs, s.Pos(), im) + ds = append(ds, im) default: panic(fmt.Sprintf( "unexpected decl spec %v", reflect.TypeOf(s))) } } + return ds } diff --git a/gnovm/tests/files/const9.gno b/gnovm/tests/files/const9.gno index 21bb7dbc753..2dbfdca2da3 100644 --- a/gnovm/tests/files/const9.gno +++ b/gnovm/tests/files/const9.gno @@ -14,4 +14,4 @@ func main() { } // Error: -// main/files/const9.gno:1: constant definition loop with b +// main/files/const9.gno:5: constant definition loop with b diff --git a/gnovm/tests/files/import6.gno b/gnovm/tests/files/import6.gno index da5dbfbd3b2..831e892ad1e 100644 --- a/gnovm/tests/files/import6.gno +++ b/gnovm/tests/files/import6.gno @@ -7,4 +7,4 @@ func main() { } // Error: -// github.com/gnolang/gno/_test/c2/c2.gno:1: import cycle detected: "github.com/gnolang/gno/_test/c1" (through [github.com/gnolang/gno/_test/c1 github.com/gnolang/gno/_test/c2]) +// github.com/gnolang/gno/_test/c2/c2.gno:3: import cycle detected: "github.com/gnolang/gno/_test/c1" (through [github.com/gnolang/gno/_test/c1 github.com/gnolang/gno/_test/c2])