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

master
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
1 changed files with 12 additions and 0 deletions

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 // Allow fixed arrays as `&i8` etc
if expected_sym.is_number() { if expected_sym.is_number() {
return true 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() { if expected_sym.kind == .enum_ && got_sym.is_number() {