mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parent
05fc7d3a72
commit
4c0ea67137
@ -3760,7 +3760,7 @@ fn (mut g Gen) unlock_locks() {
|
||||
|
||||
fn (mut g Gen) map_init(node ast.MapInit) {
|
||||
unwrap_key_typ := g.unwrap_generic(node.key_type)
|
||||
unwrap_val_typ := g.unwrap_generic(node.value_type)
|
||||
unwrap_val_typ := g.unwrap_generic(node.value_type).clear_flag(.optional).clear_flag(.result)
|
||||
key_typ_str := g.typ(unwrap_key_typ)
|
||||
value_typ_str := g.typ(unwrap_val_typ)
|
||||
value_sym := g.table.sym(unwrap_val_typ)
|
||||
|
@ -378,7 +378,7 @@ fn (mut g Gen) index_of_map(node ast.IndexExpr, sym ast.TypeSymbol) {
|
||||
elem_type_str := if elem_sym.kind == .function {
|
||||
'voidptr'
|
||||
} else {
|
||||
g.typ(elem_type)
|
||||
g.typ(elem_type.clear_flag(.optional).clear_flag(.result))
|
||||
}
|
||||
get_and_set_types := elem_sym.kind in [.struct_, .map]
|
||||
if g.is_assign_lhs && !g.is_arraymap_set && !get_and_set_types {
|
||||
|
11
vlib/v/tests/map_value_with_optional_result_test.v
Normal file
11
vlib/v/tests/map_value_with_optional_result_test.v
Normal file
@ -0,0 +1,11 @@
|
||||
import os
|
||||
|
||||
struct AdbDevice {
|
||||
opts map[string]?string
|
||||
}
|
||||
|
||||
fn test_map_value_with_optional_result() {
|
||||
// avoid warnings
|
||||
_ := os.max_path_len
|
||||
assert true
|
||||
}
|
Loading…
Reference in New Issue
Block a user