浏览代码

Improve type inference system to allow `&{}` alongside `&T{}` in some cases

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

+ 6 - 1
src/check_expr.cpp

@@ -7335,7 +7335,12 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type
 	case_ast_node(ue, UnaryExpr, node);
 		Ast *prev_unary_address_hint = c->unary_address_hint;
 		c->unary_address_hint = unparen_expr(node);
-		check_expr_base(c, o, ue->expr, type_hint);
+
+		Type *th = type_hint;
+		if (ue->op.kind == Token_And) {
+			th = type_deref(th);
+		}
+		check_expr_base(c, o, ue->expr, th);
 		c->unary_address_hint = prev_unary_address_hint;
 		node->viral_state_flags |= ue->expr->viral_state_flags;