gobra icon indicating copy to clipboard operation
gobra copied to clipboard

Pure methods cannot implement non-pure interface methods

Open jcp19 opened this issue 3 years ago • 2 comments

In the following snippet, Gobra complains that T2 does not implement the interface T1 because the 'pure' annotations of member f in the implementation and interface do not match

type T1 interface {
	f() int
}

type T2 struct{}

pure func (t T2) f() int { return 0 }

(T2) implements T1 {
	(t T2) f() int {
		return t.f()
	}
}

Maybe I am missing something, but I believe that it is sound to allow pure methods to implement non-pure ones and that this snippet should be accepted.

jcp19 avatar Jul 04 '21 22:07 jcp19

How important is this? If I am not missing something, this should be quite easy to implement.

Felalolf avatar May 11 '22 13:05 Felalolf

How important is this? If I am not missing something, this should be quite easy to implement.

This is definitely not urgent, but there were was at least a case in SCION where I found this limiting

jcp19 avatar May 11 '22 16:05 jcp19