Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
cd62122
test(gnovm): add range_blank_key filetest for nil-key range assertion
ltzmaxwell Jun 1, 2026
72007ce
fix(gnovm): guard nil kt in assertIndexTypeIsInt for blank-key range
ltzmaxwell Jun 1, 2026
fa5c11d
chore(gnovm): tighten range_blank_key fix and filetest
ltzmaxwell Jun 1, 2026
5ddcfbb
Merge remote-tracking branch 'origin/master' into fix/range_blank_key
ltzmaxwell Jun 10, 2026
5e72fed
fix(gnovm): handle blank range key/value per-operand in AssertCompatible
ltzmaxwell Jun 10, 2026
c15e60b
refactor(gnovm): rely on blank-type convention in map range check, fl…
ltzmaxwell Jun 10, 2026
fadc5fa
refactor(gnovm): drop redundant vt nil guards in range type checks
ltzmaxwell Jun 10, 2026
af1d4ba
refactor(gnovm): hoist blank-target nil case to top of checkAssignableTo
ltzmaxwell Jun 10, 2026
20da0c7
test(gnovm): add assign_range_f/g filetests (const as range value ope…
ltzmaxwell Jun 11, 2026
f2e16f1
fix(gnovm): reject unassignable range value operand in AssertCompatible
ltzmaxwell Jun 11, 2026
b77da58
test(gnovm): add assign_op_a/b and incdec_a5 filetests (unassignable …
ltzmaxwell Jun 11, 2026
f756434
fix(gnovm): validate assign target for compound assign and inc/dec st…
ltzmaxwell Jun 11, 2026
d56157a
test(gnovm): add assign_nil3 filetest (_ = nil must be rejected)
ltzmaxwell Jun 11, 2026
6c58960
fix(gnovm): reject bare untyped nil assigned to blank identifier
ltzmaxwell Jun 11, 2026
7c99b14
refactor(gnovm): require non-nil dt in checkAssignableTo, skip blank …
ltzmaxwell Jun 11, 2026
e331865
test(gnovm): add assign_range_h filetest (nil as range value operand)
ltzmaxwell Jun 11, 2026
dc75a8a
docs(gnovm): explain nil-dt ambiguity on checkAssignableTo panic
ltzmaxwell Jun 11, 2026
8e4f7bc
Merge branch 'fix/range_blank_key' into fix/assign_range_f
ltzmaxwell Jun 11, 2026
764d0b8
refactor(gnovm): panic explicitly on nil kt in assertIndexTypeIsInt
ltzmaxwell Jun 11, 2026
61c7d56
Merge branch 'fix/range_blank_key' into fix/assign_range_f
ltzmaxwell Jun 11, 2026
935a2dc
refactor(gnovm): ask assertValidAssignLhs for blank range key too, li…
ltzmaxwell Jun 11, 2026
b3e89b1
Merge branch 'fix/range_blank_key' into fix/assign_range_f
ltzmaxwell Jun 11, 2026
c8ff60e
refactor(gnovm): ask assertValidAssignLhs for blank range value too
ltzmaxwell Jun 11, 2026
2b86b9f
refactor(gnovm): restructure range checks per-operand instead of per-…
ltzmaxwell Jun 11, 2026
bcf2d9f
Merge branch 'fix/assign_range_f' into fix/range_blank_key
ltzmaxwell Jun 11, 2026
87c1804
refactor(gnovm): extract evalAssignLhsType helper for validity+type o…
ltzmaxwell Jun 11, 2026
e7347e3
refactor(gnovm): use evalAssignLhsType in remaining AssignStmt branches
ltzmaxwell Jun 11, 2026
1e7d7df
test(gnovm): add assign_op_c filetest (blank as compound-assign target)
ltzmaxwell Jun 11, 2026
248bd40
fix(gnovm): reject blank identifier as compound-assign target with pr…
ltzmaxwell Jun 11, 2026
e7a1197
refactor(gnovm): give IncDecStmt.AssertCompatible the assigning-state…
ltzmaxwell Jun 12, 2026
542a673
test(gnovm): add assign_op_d/e/f filetests (invalid compound-assign RHS)
ltzmaxwell Jun 12, 2026
0af1981
fix(gnovm): run assertValidAssignRhs for compound assignments too
ltzmaxwell Jun 12, 2026
c654faf
test(gnovm): add filetests for range/index ,ok over declared map types
ltzmaxwell Jun 12, 2026
693898f
fix(gnovm): use baseOf in range and map-index ,ok operand checks for …
ltzmaxwell Jun 12, 2026
e1b2677
test(gnovm): add assign_range_j (named int range key); sync c/d goldens
ltzmaxwell Jun 12, 2026
eddaff3
fix(gnovm): check range index by assignability to int, not kind
ltzmaxwell Jun 12, 2026
e7ce39d
test(gnovm): add assign_range_k (named rune range value); sync e golden
ltzmaxwell Jun 12, 2026
448ff33
fix(gnovm): check string range value by assignability to int32, not kind
ltzmaxwell Jun 12, 2026
17ab57c
test(gnovm): add assign_op_g order pin (invalid RHS wins over unassig…
ltzmaxwell Jun 12, 2026
96871b4
refactor(gnovm): fold identical slice/array value case in range check
ltzmaxwell Jun 12, 2026
0c99046
test(gnovm): pin define from nil interface conversion (assign_nil4)
ltzmaxwell Jun 12, 2026
5d5a459
docs(gnovm): clarify blank-nil rejection comment in assertValidAssignRhs
ltzmaxwell Jun 12, 2026
0509a19
refactor(gnovm): only folded ConstExpr counts as bare nil; panic on u…
ltzmaxwell Jun 12, 2026
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
7 changes: 4 additions & 3 deletions gnovm/pkg/gnolang/type_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,9 @@ func (x *IncDecStmt) AssertCompatible(t Type) {
}

func assertIndexTypeIsInt(kt Type) {
if kt == nil {
return
}
if kt.Kind() != IntKind {
panic(fmt.Sprintf("index type should be int, but got %v", kt))
}
Expand Down Expand Up @@ -861,9 +864,7 @@ func (x *RangeStmt) AssertCompatible(store Store, last BlockNode) {
}
case PrimitiveType:
if cxt.Kind() == StringKind {
if kt != nil && kt.Kind() != IntKind {
panic(fmt.Sprintf("index type should be int, but got %v", kt))
}
assertIndexTypeIsInt(kt)
if vt != nil {
if vt.Kind() != Int32Kind { // rune
panic(fmt.Sprintf("value type should be int32, but got %v", kt))
Expand Down
11 changes: 11 additions & 0 deletions gnovm/tests/files/range_blank_key.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

// Regression: `for _ = range slice` used to panic on nil key in assertIndexTypeIsInt.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also fix

package main

func main() {
	a := []int{1, 2, 3}
	var v int
	for _, v = range a {
	}
	_ = v
	println("ok")
}

// Output:
// ok

Ref: #5751 (comment) (+ verified personally)


func main() {
s := []int{1, 2, 3}
for _ = range s {
}
}

// Output:
Loading