mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: fix map with optional or result on return (#16044)
This commit is contained in:
parent
12d3664a09
commit
9569c0504c
@ -378,7 +378,11 @@ fn (mut g Gen) index_of_map(node ast.IndexExpr, sym ast.TypeSymbol) {
|
|||||||
elem_type_str := if elem_sym.kind == .function {
|
elem_type_str := if elem_sym.kind == .function {
|
||||||
'voidptr'
|
'voidptr'
|
||||||
} else {
|
} else {
|
||||||
g.typ(elem_type.clear_flag(.optional).clear_flag(.result))
|
if g.inside_return {
|
||||||
|
g.typ(elem_type)
|
||||||
|
} else {
|
||||||
|
g.typ(elem_type.clear_flag(.optional).clear_flag(.result))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
get_and_set_types := elem_sym.kind in [.struct_, .map]
|
get_and_set_types := elem_sym.kind in [.struct_, .map]
|
||||||
if g.is_assign_lhs && !g.is_arraymap_set && !get_and_set_types {
|
if g.is_assign_lhs && !g.is_arraymap_set && !get_and_set_types {
|
||||||
|
@ -9,3 +9,7 @@ fn test_map_value_with_optional_result() {
|
|||||||
_ := os.max_path_len
|
_ := os.max_path_len
|
||||||
assert true
|
assert true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn foo(arg map[string]?string) ?string {
|
||||||
|
return arg['akey']
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user