Support string literals for fixed arrays of runes; Add %q support for arrays/slices of bytes

This commit is contained in:
gingerBill
2020-11-20 16:24:23 +00:00
parent 6416a6f39c
commit 63e4a2341f
6 changed files with 96 additions and 29 deletions

View File

@@ -2955,10 +2955,17 @@ 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)) {
if (operand->value.kind == ExactValue_String) {
String s = operand->value.value_string;
if (s.len == t->Array.count) {
break;
if (is_type_u8_array(t)) {
if (s.len == t->Array.count) {
break;
}
} else if (is_type_rune_array(t)) {
isize rune_count = s.len;
if (rune_count == t->Array.count) {
break;
}
}
}
operand->mode = Addressing_Invalid;