Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions gnovm/tests/files/method38.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// This test with method39.gno are answers to this issue: https://github.com/gnolang/gno/issues/4789
package main

import "fmt"

type B struct{}

func (B) Foo() string { return "Foo from B" }

type A struct{ B } // embeds B
type T A // T retains the struct layout of A (embedding B)
type S struct{ T } // S embeds T (which embeds B)

func main() {
var s S
fmt.Println(s.Foo())
fmt.Println("ok")
}

// Output:
// Foo from B
// ok
19 changes: 19 additions & 0 deletions gnovm/tests/files/method39.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// This test with method38.gno are answers to this issue: https://github.com/gnolang/gno/issues/4789
package main

type Base struct{}

func (Base) Foo() {}

type Derived Base // declared type does not inherit methods

func main() {
var d Derived
d.Foo() // want: method not found
}

// Error:
// main/method39.gno:12:2-7: missing field Foo in main.Derived

// TypeCheckError:
// main/method39.gno:12:4: d.Foo undefined (type Derived has no field or method Foo)
Loading