checker: fix returning optional empty map (#13113)
parent
7f1cc44b04
commit
02f791d9fe
|
@ -202,7 +202,7 @@ pub fn (mut c Checker) map_init(mut node ast.MapInit) ast.Type {
|
|||
sym := c.table.sym(c.expected_type)
|
||||
if sym.kind == .map {
|
||||
info := sym.map_info()
|
||||
node.typ = c.expected_type
|
||||
node.typ = c.expected_type.clear_flag(.optional)
|
||||
node.key_type = info.key_type
|
||||
node.value_type = info.value_type
|
||||
return node.typ
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
fn opt() ?map[string]string {
|
||||
return {}
|
||||
}
|
||||
|
||||
fn test_option_empty_map() {
|
||||
x := opt() or {
|
||||
assert false
|
||||
return
|
||||
}
|
||||
|
||||
dump(x)
|
||||
assert '$x' == '{}'
|
||||
}
|
Loading…
Reference in New Issue