1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

checker: allow fixed array to pointer and vice versa when translated (#14275)

This commit is contained in:
playX 2022-05-03 17:44:45 +00:00 committed by GitHub
parent 04a77c731e
commit 146051b231
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -43,6 +43,18 @@ pub fn (mut c Checker) check_types(got ast.Type, expected ast.Type) bool {
// Allow fixed arrays as `&i8` etc
if expected_sym.is_number() {
return true
} else if expected.is_any_kind_of_pointer() {
return true
}
} else if expected_sym.kind == .array_fixed {
if got_sym.is_number() && got.is_any_kind_of_pointer() {
return true
} else if got_sym.kind == .array {
info := expected_sym.info as ast.ArrayFixed
info2 := got_sym.info as ast.Array
if c.check_types(info.elem_type, info2.elem_type) {
return true
}
}
}
if expected_sym.kind == .enum_ && got_sym.is_number() {