Skip to content

Commit

Permalink
clean up, fixed test
Browse files Browse the repository at this point in the history
  • Loading branch information
deelawn committed Jul 31, 2024
1 parent c94aff0 commit e108f69
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 8 additions & 3 deletions gnovm/pkg/gnolang/preprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -2172,15 +2172,20 @@ func Preprocess(store Store, ctx BlockNode, n Node) Node {

var tuple *tupleType
valueExpr := n.Values[0]
valueType := evalStaticTypeOfRaw(store, last, valueExpr)

switch expr := valueExpr.(type) {
case *CallExpr:
tuple = evalStaticTypeOfRaw(store, last, expr).(*tupleType)
tuple = valueType.(*tupleType)
case *TypeAssertExpr, *IndexExpr:
valueType := evalStaticTypeOfRaw(store, last, expr)
tuple = &tupleType{Elts: []Type{valueType, BoolType}}
if ex, ok := expr.(*TypeAssertExpr); ok {
ex.HasOK = true
break
}
expr.(*IndexExpr).HasOK = true
default:
panic(fmt.Sprintf("unexpected ValueDecl value expression type %T", expr))

Check warning on line 2188 in gnovm/pkg/gnolang/preprocess.go

View check run for this annotation

Codecov / codecov/patch

gnovm/pkg/gnolang/preprocess.go#L2187-L2188

Added lines #L2187 - L2188 were not covered by tests

}

if rLen := len(tuple.Elts); rLen != numNames {
Expand Down
6 changes: 3 additions & 3 deletions gnovm/tests/files/vardecl.gno
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package main

func main() {
var i interface{} = 1
a, ok := i.(int)
var a, ok = i.(int)
println(a, ok)

b, c := doSomething()
var b, c = doSomething()
println(b, c)

m := map[string]int{"a": 1, "b": 2}
d, okk := m["d"]
var d, okk = m["d"]
println(d, okk)
}

Expand Down

0 comments on commit e108f69

Please sign in to comment.