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(gnovm): in op_binary, return typed booleans where appropriate #3298

Merged
merged 4 commits into from
Dec 11, 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
4 changes: 4 additions & 0 deletions gnovm/pkg/gnolang/preprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -3574,6 +3574,10 @@ func checkOrConvertType(store Store, last BlockNode, n Node, x *Expr, t Type, au
checkOrConvertType(store, last, n, &bx.Left, rt, autoNative)
checkOrConvertType(store, last, n, &bx.Right, rt, autoNative)
}
// this is not a constant expression; the result here should
// always be a BoolType. (in this scenario, we may have some
// UntypedBoolTypes)
t = BoolType
default:
// do nothing
}
Expand Down
17 changes: 17 additions & 0 deletions gnovm/tests/files/bool8.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package main

// results from comparisons should not be untyped bools

var a interface{} = true

func main() {
buf := "hello="
isEqual(a, (buf[len(buf)-1] == '='))
}

func isEqual(v1, v2 interface{}) {
thehowl marked this conversation as resolved.
Show resolved Hide resolved
println("v1 == v2", v1 == v2)
}

// Output:
// v1 == v2 true
Loading