浏览代码

#4115 Add `Suggestion: 'typeid_of(T)'`

gingerBill 1 年之前
父节点
当前提交
00fb60d3d9
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      src/check_expr.cpp

+ 4 - 0
src/check_expr.cpp

@@ -1180,11 +1180,15 @@ gb_internal void check_assignment(CheckerContext *c, Operand *operand, Type *typ
 				      LIT(article),
 				      LIT(article),
 				      LIT(context_name));
 				      LIT(context_name));
 			} else {
 			} else {
+				ERROR_BLOCK();
 				error(operand->expr,
 				error(operand->expr,
 				      "Cannot assign '%s', a type, to %.*s%.*s",
 				      "Cannot assign '%s', a type, to %.*s%.*s",
 				      op_type_str,
 				      op_type_str,
 				      LIT(article),
 				      LIT(article),
 				      LIT(context_name));
 				      LIT(context_name));
+				if (type && are_types_identical(type, t_any)) {
+					error_line("\tSuggestion: 'typeid_of(%s)'", expr_str);
+				}
 			}
 			}
 			break;
 			break;
 		default:
 		default: