Allow string literals for [N]byte

This commit is contained in:
gingerBill
2020-11-20 16:01:59 +00:00
parent 87956676f5
commit 6416a6f39c
6 changed files with 34 additions and 7 deletions

View File

@@ -2955,6 +2955,12 @@ void convert_to_typed(CheckerContext *c, Operand *operand, Type *target_type) {
if (check_is_assignable_to(c, operand, elem)) {
operand->mode = Addressing_Value;
} else {
if (operand->value.kind == ExactValue_String && is_type_u8_array(t)) {
String s = operand->value.value_string;
if (s.len == t->Array.count) {
break;
}
}
operand->mode = Addressing_Invalid;
convert_untyped_error(c, operand, target_type);
return;