gingerBill 4 years ago
parent
commit
2e5f57d8a1
3 changed files with 17 additions and 17 deletions
  1. 3 1
      src/check_expr.cpp
  2. 11 14
      src/check_type.cpp
  3. 3 2
      src/llvm_backend.cpp

+ 3 - 1
src/check_expr.cpp

@@ -621,7 +621,9 @@ i64 check_distance_between_types(CheckerContext *c, Operand *operand, Type *type
 		}
 		}
 		PolyProcData poly_proc_data = {};
 		PolyProcData poly_proc_data = {};
 		if (check_polymorphic_procedure_assignment(c, operand, type, operand->expr, &poly_proc_data)) {
 		if (check_polymorphic_procedure_assignment(c, operand, type, operand->expr, &poly_proc_data)) {
-			add_entity_use(c, operand->expr, poly_proc_data.gen_entity);
+			Entity *e = poly_proc_data.gen_entity;
+			add_type_and_value(c->info, operand->expr, Addressing_Value, e->type, {});
+			add_entity_use(c, operand->expr, e);
 			return 4;
 			return 4;
 		}
 		}
 	}
 	}

+ 11 - 14
src/check_type.cpp

@@ -1207,6 +1207,11 @@ ParameterValue handle_parameter_value(CheckerContext *ctx, Type *in_type, Type *
 		init_core_source_code_location(ctx->checker);
 		init_core_source_code_location(ctx->checker);
 		param_value.kind = ParameterValue_Location;
 		param_value.kind = ParameterValue_Location;
 		o.type = t_source_code_location;
 		o.type = t_source_code_location;
+
+		if (in_type) {
+			check_assignment(ctx, &o, in_type, str_lit("parameter value"));
+		}
+
 	} else {
 	} else {
 		if (in_type) {
 		if (in_type) {
 			check_expr_with_type_hint(ctx, &o, expr, in_type);
 			check_expr_with_type_hint(ctx, &o, expr, in_type);
@@ -1214,6 +1219,11 @@ ParameterValue handle_parameter_value(CheckerContext *ctx, Type *in_type, Type *
 			check_expr(ctx, &o, expr);
 			check_expr(ctx, &o, expr);
 		}
 		}
 
 
+		if (in_type) {
+			check_assignment(ctx, &o, in_type, str_lit("parameter value"));
+		}
+
+
 		if (is_operand_nil(o)) {
 		if (is_operand_nil(o)) {
 			param_value.kind = ParameterValue_Nil;
 			param_value.kind = ParameterValue_Nil;
 		} else if (o.mode != Addressing_Constant) {
 		} else if (o.mode != Addressing_Constant) {
@@ -1221,16 +1231,7 @@ ParameterValue handle_parameter_value(CheckerContext *ctx, Type *in_type, Type *
 				param_value.kind = ParameterValue_Constant;
 				param_value.kind = ParameterValue_Constant;
 				param_value.value = exact_value_procedure(expr);
 				param_value.value = exact_value_procedure(expr);
 			} else {
 			} else {
-				Entity *e = nullptr;
-				// if (o.mode == Addressing_Value && is_type_proc(o.type)) {
-				if (o.mode == Addressing_Value || o.mode == Addressing_Variable) {
-					Operand x = {};
-					if (expr->kind == Ast_Ident) {
-						e = check_ident(ctx, &x, expr, nullptr, nullptr, false);
-					} else if (expr->kind == Ast_SelectorExpr) {
-						e = check_selector(ctx, &x, expr, nullptr);
-					}
-				}
+				Entity *e = entity_from_expr(o.expr);
 
 
 				if (e != nullptr) {
 				if (e != nullptr) {
 					if (e->kind == Entity_Procedure) {
 					if (e->kind == Entity_Procedure) {
@@ -1267,10 +1268,6 @@ ParameterValue handle_parameter_value(CheckerContext *ctx, Type *in_type, Type *
 		}
 		}
 	}
 	}
 
 
-	if (in_type) {
-		check_assignment(ctx, &o, in_type, str_lit("parameter value"));
-	}
-
 	if (out_type_) {
 	if (out_type_) {
 		if (in_type != nullptr) {
 		if (in_type != nullptr) {
 			*out_type_ = in_type;
 			*out_type_ = in_type;

+ 3 - 2
src/llvm_backend.cpp

@@ -6023,7 +6023,7 @@ lbValue lb_const_value(lbModule *m, Type *type, ExactValue value, bool allow_loc
 			res.value = llvm_const_array(et, elems, cast(unsigned)count);
 			res.value = llvm_const_array(et, elems, cast(unsigned)count);
 			return res;
 			return res;
 		}
 		}
-		GB_PANIC("HERE!\n");
+		GB_PANIC("This should not have happened!\n");
 
 
 		LLVMValueRef data = LLVMConstStringInContext(ctx,
 		LLVMValueRef data = LLVMConstStringInContext(ctx,
 			cast(char const *)value.value_string.text,
 			cast(char const *)value.value_string.text,
@@ -9715,7 +9715,8 @@ lbValue lb_handle_param_value(lbProcedure *p, Type *parameter_type, ParameterVal
 	switch (param_value.kind) {
 	switch (param_value.kind) {
 	case ParameterValue_Constant:
 	case ParameterValue_Constant:
 		if (is_type_constant_type(parameter_type)) {
 		if (is_type_constant_type(parameter_type)) {
-			return lb_const_value(p->module, parameter_type, param_value.value);
+			auto res = lb_const_value(p->module, parameter_type, param_value.value);
+			return res;
 		} else {
 		} else {
 			ExactValue ev = param_value.value;
 			ExactValue ev = param_value.value;
 			lbValue arg = {};
 			lbValue arg = {};