Skip to content

Commit

Permalink
proper err msg
Browse files Browse the repository at this point in the history
  • Loading branch information
ltzmaxwell committed Apr 10, 2024
1 parent 25f204c commit a2521a5
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 9 deletions.
4 changes: 2 additions & 2 deletions gnovm/pkg/gnolang/preprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -2957,10 +2957,10 @@ func predefineNow2(store Store, last BlockNode, d Decl, m map[Name]struct{}) (De
// check base type of receiver type, should not be pointer type or interface type
assertValidReceiverType := func(t Type) {
if _, ok := t.(*PointerType); ok {
panic(fmt.Sprintf("invalid receiver type %v (pointer type)\n", rt))
panic(fmt.Sprintf("invalid receiver type %v (base type is pointer type)\n", rt))
}
if _, ok := t.(*InterfaceType); ok {
panic(fmt.Sprintf("invalid receiver type %v (interface type)\n", rt))
panic(fmt.Sprintf("invalid receiver type %v (base type is interface type)\n", rt))
}
}

Expand Down
2 changes: 1 addition & 1 deletion gnovm/tests/files/type37.gno
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ func main() {
}

// Error:
// main/files/type37.gno:8: invalid receiver type main.Arr (pointer type)
// main/files/type37.gno:8: invalid receiver type main.Arr (base type is pointer type)
2 changes: 1 addition & 1 deletion gnovm/tests/files/type37b.gno
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ func main() {
}

// Error:
// main/files/type37b.gno:7: invalid receiver type **main.Integer (pointer type)
// main/files/type37b.gno:7: invalid receiver type **main.Integer (base type is pointer type)
2 changes: 1 addition & 1 deletion gnovm/tests/files/type37d.gno
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ func main() {
}

// Error:
// main/files/type37d.gno:7: invalid receiver type main.IntPtr (pointer type)
// main/files/type37d.gno:7: invalid receiver type main.IntPtr (base type is pointer type)
2 changes: 1 addition & 1 deletion gnovm/tests/files/type37e.gno
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ func main() {
}

// Error:
// main/files/type37e.gno:8: invalid receiver type main.Int2 (pointer type)
// main/files/type37e.gno:8: invalid receiver type main.Int2 (base type is pointer type)
16 changes: 16 additions & 0 deletions gnovm/tests/files/type37f.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package main

type IntPtr *int

var ip IntPtr = new(int)

func (p *IntPtr) Int() int {
return **p
}

func main() {
println((&ip).Int())
}

// Error:
// main/files/type37f.gno:7: invalid receiver type *main.IntPtr (base type is pointer type)
2 changes: 1 addition & 1 deletion gnovm/tests/files/type39.gno
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ func main() {
}

// Error:
// main/files/type39.gno:7: invalid receiver type main.foo (interface type)
// main/files/type39.gno:7: invalid receiver type main.foo (base type is interface type)
2 changes: 1 addition & 1 deletion gnovm/tests/files/type39a.gno
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ func main() {
}

// Error:
// main/files/type39a.gno:9: invalid receiver type main.FF (interface type)
// main/files/type39a.gno:9: invalid receiver type main.FF (base type is interface type)
2 changes: 1 addition & 1 deletion gnovm/tests/files/type39b.gno
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ func main() {
}

// Error:
// main/files/type39b.gno:7: invalid receiver type *main.foo (interface type)
// main/files/type39b.gno:7: invalid receiver type *main.foo (base type is interface type)

0 comments on commit a2521a5

Please sign in to comment.