aboutsummaryrefslogtreecommitdiff
path: root/src/stage1/ir.cpp
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2020-12-19 22:27:24 +0100
committerAndrew Kelley <andrew@ziglang.org>2020-12-19 19:45:48 -0500
commit84549b42678fa1f2755b2ec7bf4f4936d8f513af (patch)
tree6d1b3222ce827cc7e166f6cc15b6d81d4421b8c8 /src/stage1/ir.cpp
parentdd7b816d98840f26988c993eda9be21fa9b0ab50 (diff)
downloadzig-84549b42678fa1f2755b2ec7bf4f4936d8f513af.tar.gz
zig-84549b42678fa1f2755b2ec7bf4f4936d8f513af.zip
stage1: Fix for generic fn monomorphization
Don't use the instantiation argument types to build the function parameter array. f416535768fc30195cad6cd481f73fd1e80082aa worked around the problem, this commit solves it.
Diffstat (limited to 'src/stage1/ir.cpp')
-rw-r--r--src/stage1/ir.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/stage1/ir.cpp b/src/stage1/ir.cpp
index fb94762b05..0e1c659642 100644
--- a/src/stage1/ir.cpp
+++ b/src/stage1/ir.cpp
@@ -20226,9 +20226,12 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod
bool is_var_args = param_decl_node->data.param_decl.is_var_args;
bool arg_part_of_generic_id = false;
IrInstGen *casted_arg;
+
+ ZigType *param_info_type = nullptr;
if (is_var_args) {
arg_part_of_generic_id = true;
casted_arg = arg;
+ param_info_type = arg->value->type;
} else {
if (param_decl_node->data.param_decl.anytype_token == nullptr) {
AstNode *param_type_node = param_decl_node->data.param_decl.type;
@@ -20239,9 +20242,12 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod
casted_arg = ir_implicit_cast2(ira, arg_src, arg, param_type);
if (type_is_invalid(casted_arg->value->type))
return false;
+
+ param_info_type = param_type;
} else {
arg_part_of_generic_id = true;
casted_arg = arg;
+ param_info_type = arg->value->type;
}
}
@@ -20298,7 +20304,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod
if (!comptime_arg) {
casted_args[fn_type_id->param_count] = casted_arg;
FnTypeParamInfo *param_info = &fn_type_id->param_info[fn_type_id->param_count];
- param_info->type = casted_arg->value->type;
+ param_info->type = param_info_type;
param_info->is_noalias = param_decl_node->data.param_decl.is_noalias;
impl_fn->param_source_nodes[fn_type_id->param_count] = param_decl_node;
fn_type_id->param_count += 1;