Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: untyped to interface check #2042

Merged
merged 8 commits into from
May 7, 2024
Merged
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
3 changes: 3 additions & 0 deletions gnovm/pkg/gnolang/preprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
16 changes: 16 additions & 0 deletions gnovm/tests/files/fun27.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package main

type Foo interface {
foo()
}

func NewSet() Foo {
return 1
}

func main() {
NewSet()
}

// Error:
// main/files/fun27.gno:8: <untyped> bigint does not implement main.Foo
Loading