diff options
| author | gingerBill <bill@gingerbill.org> | 2020-11-20 16:24:23 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2020-11-20 16:24:23 +0000 |
| commit | 63e4a2341f1409eec1f2e58036cd01b24b66b8f0 (patch) | |
| tree | 93801df8d25cb3c09c77d293fa4a53a513bb4383 /src/check_expr.cpp | |
| parent | 6416a6f39cce4c65c80e29bb4ff4b93a3e463947 (diff) | |
Support string literals for fixed arrays of runes; Add %q support for arrays/slices of bytes
Diffstat (limited to 'src/check_expr.cpp')
| -rw-r--r-- | src/check_expr.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index f258253f5..c67ad22b8 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -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; |