checker: correctly check arrays with element that is an alias. fixes #6735
parent
0c18b3bea6
commit
cf7b45b074
|
@ -85,14 +85,27 @@ pub fn (mut c Checker) check_basic(got table.Type, expected table.Type) bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO
|
// TODO
|
||||||
if exp_type_sym.name == 'array' || got_type_sym.name == 'array' {
|
// if exp_type_sym.name == 'array' || got_type_sym.name == 'array' {
|
||||||
|
if got_idx == table.array_type_idx || exp_idx == table.array_type_idx {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// TODO
|
if got_type_sym.kind == .array && exp_type_sym.kind == .array {
|
||||||
// accept [] when an expected type is an array
|
// TODO
|
||||||
if got_type_sym.kind == .array &&
|
// accept [] when an expected type is an array
|
||||||
got_type_sym.name == 'array_void' && exp_type_sym.kind == .array {
|
if got_type_sym.name == 'array_void' {
|
||||||
return true
|
return true
|
||||||
|
}
|
||||||
|
// if elem_type is an alias, check it
|
||||||
|
// TODO: think about recursion, how many levels of alias can there be?
|
||||||
|
got_info := got_type_sym.info as table.Array
|
||||||
|
exp_info := exp_type_sym.info as table.Array
|
||||||
|
got_elem_sym := c.table.get_type_symbol(got_info.elem_type)
|
||||||
|
exp_elem_sym := c.table.get_type_symbol(exp_info.elem_type)
|
||||||
|
if (got_elem_sym.kind == .alias ||
|
||||||
|
exp_elem_sym.kind == .alias) &&
|
||||||
|
c.check_basic(got_info.elem_type, exp_info.elem_type) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// type alias
|
// type alias
|
||||||
if (got_type_sym.kind == .alias &&
|
if (got_type_sym.kind == .alias &&
|
||||||
|
|
Loading…
Reference in New Issue