Skip to content

Commit

Permalink
datatypes: fix linked list of map (fix #17570) (#17573)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyi98 committed Mar 9, 2023
1 parent d353dd6 commit 71c3b66
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion vlib/datatypes/linked_list.v
Expand Up @@ -207,7 +207,7 @@ pub fn (mut iter ListIter[T]) next() ?T {
if iter.node == unsafe { nil } {
return none
}
res := iter.node.data
res := unsafe { iter.node.data }
iter.node = iter.node.next
return res
}
23 changes: 23 additions & 0 deletions vlib/datatypes/linked_list_test.v
Expand Up @@ -168,3 +168,26 @@ fn test_linked_list_separate_iterators() {
}
assert res == [1, 2, 3]
}

struct Foo {
mut:
field LinkedList[map[string]int]
}

fn test_linked_list_map() {
mut foo := Foo{}
foo.field.push({
'one': 1
})
foo.field.push({
'two': 2
})
println(foo)
mut iter := foo.field.iterator()
assert iter.next()! == {
'one': 1
}
assert iter.next()! == {
'two': 2
}
}

0 comments on commit 71c3b66

Please sign in to comment.