diff --git a/gnovm/pkg/gnolang/preprocess.go b/gnovm/pkg/gnolang/preprocess.go index 64fe1fbff45..12cf78cb7fa 100644 --- a/gnovm/pkg/gnolang/preprocess.go +++ b/gnovm/pkg/gnolang/preprocess.go @@ -2472,6 +2472,9 @@ func convertIfConst(store Store, last BlockNode, x Expr) { func convertConst(store Store, last BlockNode, cx *ConstExpr, t Type) { if t != nil && t.Kind() == InterfaceKind { + if cx.T != nil { + checkType(cx.T, t, false) + } t = nil // signifies to convert to default type. } if isUntyped(cx.T) { diff --git a/gnovm/tests/files/fun27.gno b/gnovm/tests/files/fun27.gno new file mode 100644 index 00000000000..4e6e25e1065 --- /dev/null +++ b/gnovm/tests/files/fun27.gno @@ -0,0 +1,16 @@ +package main + +type Foo interface { + foo() +} + +func NewSet() Foo { + return 1 +} + +func main() { + NewSet() +} + +// Error: +// main/files/fun27.gno:8: bigint does not implement main.Foo