diff options
| author | JasperGeer <jasper.geer@gmail.com> | 2022-10-23 19:41:07 -0400 |
|---|---|---|
| committer | JasperGeer <jasper.geer@gmail.com> | 2022-10-23 19:41:07 -0400 |
| commit | 1a0930f841f6704b78d75f7e33eab973d71477d6 (patch) | |
| tree | 5b10f7cdf9f4a14218280109777832fb48b1c829 /src/check_expr.cpp | |
| parent | a5f8c3f692ff802104b81416513396981409c2f3 (diff) | |
don't suggest u8 slice cast to string for u8 slice literal
Diffstat (limited to 'src/check_expr.cpp')
| -rw-r--r-- | src/check_expr.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index b3c04caa4..37254da01 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -1998,7 +1998,7 @@ void check_assignment_error_suggestion(CheckerContext *c, Operand *o, Type *type error_line("\tSuggestion: a string may be transmuted to %s\n", b); error_line("\t This is an UNSAFE operation as string data is assumed to be immutable, \n"); error_line("\t whereas slices in general are assumed to be mutable.\n"); - } else if (is_type_u8_slice(src) && are_types_identical(dst, t_string)) { + } else if (is_type_u8_slice(src) && are_types_identical(dst, t_string) && o->expr->kind != Ast_CompoundLit) { error_line("\tSuggestion: the expression may be casted to %s\n", b); } } @@ -2039,7 +2039,7 @@ void check_cast_error_suggestion(CheckerContext *c, Operand *o, Type *type) { } } else if (are_types_identical(src, t_string) && is_type_u8_slice(dst)) { error_line("\tSuggestion: a string may be transmuted to %s\n", b); - } else if (is_type_u8_slice(src) && are_types_identical(dst, t_string)) { + } else if (is_type_u8_slice(src) && are_types_identical(dst, t_string) && o->expr->kind != Ast_CompoundLit) { error_line("\tSuggestion: the expression may be casted to %s\n", b); } } |