mirror of
https://github.com/vlang/v.git
synced 2025-08-03 09:47:15 -04:00
parent
f834855cb5
commit
198ecd09bc
@ -628,7 +628,7 @@ fn (mut w Walker) expr(node_ ast.Expr) {
|
||||
w.expr(node.expr)
|
||||
w.mark_by_type(node.expr_type)
|
||||
w.uses_guard = true
|
||||
if node.expr_type != 0 && !w.uses_str_index_check
|
||||
if node.expr_type != 0 && !w.uses_str_index_check && node.expr is ast.IndexExpr
|
||||
&& w.table.final_sym(node.expr_type).kind in [.u8, .string] {
|
||||
w.uses_str_index_check = true
|
||||
}
|
||||
@ -1296,9 +1296,6 @@ fn (mut w Walker) mark_resource_dependencies() {
|
||||
if w.uses_mem_align {
|
||||
w.fn_by_name('memdup_align')
|
||||
}
|
||||
if w.uses_guard || w.uses_check_index {
|
||||
w.fn_by_name('error')
|
||||
}
|
||||
if w.uses_spawn {
|
||||
w.fn_by_name('malloc')
|
||||
w.fn_by_name('tos3')
|
||||
@ -1407,6 +1404,9 @@ fn (mut w Walker) mark_resource_dependencies() {
|
||||
continue
|
||||
}
|
||||
}
|
||||
if w.uses_guard || w.uses_check_index {
|
||||
w.fn_by_name('error')
|
||||
}
|
||||
if w.uses_append {
|
||||
ref_array_idx_str := int(ast.array_type.ref()).str()
|
||||
w.fn_by_name(ref_array_idx_str + '.push')
|
||||
|
21
vlib/v/tests/generics/struct_generic_map_index_test.v
Normal file
21
vlib/v/tests/generics/struct_generic_map_index_test.v
Normal file
@ -0,0 +1,21 @@
|
||||
pub struct Set[T] {
|
||||
mut:
|
||||
elements map[T]u8
|
||||
}
|
||||
|
||||
pub fn (l Set[T]) == (r Set[T]) bool {
|
||||
if l.elements.len != r.elements.len {
|
||||
return false
|
||||
}
|
||||
for key, l_val in l.elements {
|
||||
r_val := r.elements[key] or { return false }
|
||||
if l_val != r_val {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
fn test_main() {
|
||||
_ := Set[int]{}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user