Skip to content

Commit

Permalink
fix: untyped to interface check (#2042)
Browse files Browse the repository at this point in the history
solves [issue](#2023)

<details><summary>Contributors' checklist...</summary>

- [x] Added new tests, or not needed, or not feasible
- [x] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [x] Updated the official documentation or not needed
- [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] Added references to related issues and PRs

---------

Co-authored-by: deelawn <[email protected]>
  • Loading branch information
petar-dambovaliev and deelawn authored May 7, 2024
1 parent 4809582 commit dd68d61
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
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

0 comments on commit dd68d61

Please sign in to comment.