aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2022-11-03 12:47:44 +0000
committerGitHub <noreply@github.com>2022-11-03 12:47:44 +0000
commit3e66b880310a5fbeb04134a5d024f1a712cfca92 (patch)
treee614899eb90120da3e6a3a850fbdcd2540a2353a /src/check_expr.cpp
parent32477a88ef00b39ec3104553af1c057d157665f6 (diff)
parent4b8721a0bbdb2e8b5a7cd13705cd6007040b9a7a (diff)
Merge pull request #2147 from jaspergeer/tighten-slice-string-cast-error
fix #2095 "Suggestion: the expression may be casted to string" in response to erroneous cast to string
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index b3c04caa4..9e48fd8ad 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->mode != Addressing_Constant) {
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->mode != Addressing_Constant) {
error_line("\tSuggestion: the expression may be casted to %s\n", b);
}
}