Skip to content

Commit

Permalink
fix: verify type is ok
Browse files Browse the repository at this point in the history
  • Loading branch information
omarsy committed May 26, 2024
1 parent e1b0dc0 commit c328ed5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
5 changes: 4 additions & 1 deletion gnovm/pkg/gnolang/preprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -1857,7 +1857,10 @@ func Preprocess(store Store, ctx BlockNode, n Node) Node {
tvs := make([]TypedValue, numNames)
if numNames > 1 && len(n.Values) == 1 {
// special case if `var a, b, c T? = f()` form.
cx := n.Values[0].(*CallExpr)
cx, ok := n.Values[0].(*CallExpr)
if !ok {
panic("should not happen")

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

View check run for this annotation

Codecov / codecov/patch

gnovm/pkg/gnolang/preprocess.go#L1860-L1862

Added lines #L1860 - L1862 were not covered by tests
}
tt := evalStaticTypeOfRaw(store, last, cx).(*tupleType)
if len(tt.Elts) != numNames {
panic("should not happen")
Expand Down
7 changes: 7 additions & 0 deletions gnovm/tests/files/var18.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

func main() {
a, b := 1
}

// main/files/var18.gno:3: should not happen
11 changes: 11 additions & 0 deletions gnovm/tests/files/var19.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

func main() {
a, b, c := 1, a+1
println(a)
println(b)
println(c)
}

// Error:
// main/files/var19.gno:4: name a not declared

0 comments on commit c328ed5

Please sign in to comment.