mirror of
https://github.com/odin-lang/Odin.git
synced 2026-06-16 23:31:13 +00:00
Merge pull request #6846 from Znarf64/typeid_cast_suggestion
Add suggestion to use 'typeid_of(type)' when trying to do `typeid(type)`
This commit is contained in:
@@ -3808,7 +3808,14 @@ gb_internal bool check_cast_internal(CheckerContext *c, Operand *x, Type *type)
|
||||
|
||||
gb_internal void check_cast(CheckerContext *c, Operand *x, Type *type, bool forbid_identical = false) {
|
||||
if (!is_operand_value(*x)) {
|
||||
ERROR_BLOCK();
|
||||
error(x->expr, "Only values can be casted");
|
||||
if (is_type_typeid(type)) {
|
||||
gbString expr_str = expr_to_string(x->expr);
|
||||
defer (gb_string_free(expr_str));
|
||||
|
||||
error_line("\tSuggestion: 'typeid_of(%s)'", expr_str);
|
||||
}
|
||||
x->mode = Addressing_Invalid;
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user