Skip to content
30 changes: 30 additions & 0 deletions gnovm/cmd/gno/testdata/test/issue_5664.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# range with several combinations of key and value (presence)

gno run .

-- main.gno --
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// Issue 2821
Comment thread
ltzmaxwell marked this conversation as resolved.
Outdated
package main

type matrix struct {
e []int
}

func (a matrix) equal() bool {
for _ = range a.e {
}
for range a.e {
}
return true
}

func main() {
Comment thread
ltzmaxwell marked this conversation as resolved.
Outdated
var a matrix
var i interface{}
i = true && a.equal()
_ = i
}
4 changes: 2 additions & 2 deletions gnovm/pkg/gnolang/type_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -829,8 +829,8 @@ func (x *RangeStmt) AssertCompatible(store Store, last BlockNode) {
if x.Op != ASSIGN {
return
}
if isBlankIdentifier(x.Key) && isBlankIdentifier(x.Value) {
// both "_"
if isBlankIdentifier(x.Key) && (x.Value == nil || isBlankIdentifier(x.Value)) {
// both "_" or key is "_" and value is not present
return
}
assertValidAssignLhs(store, last, x.Key)
Expand Down
Loading