aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-12-09 13:30:53 -0500
committerAndrew Kelley <andrew@ziglang.org>2019-12-09 13:30:53 -0500
commit5d82744f1cb3ea66c20fc377d0237a50ccbcf81e (patch)
treea5da5c96fe71492cbf5d29a2e96b6cfe45a3793e /src/ir.cpp
parent640e09183d3100c477a26c6cdc26f1eae31472a1 (diff)
downloadzig-5d82744f1cb3ea66c20fc377d0237a50ccbcf81e.tar.gz
zig-5d82744f1cb3ea66c20fc377d0237a50ccbcf81e.zip
ability to give comptime and non-comptime types to same parameter
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 0f66965a80..59fd21aace 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -17359,8 +17359,18 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod
}
}
- bool comptime_arg = param_decl_node->data.param_decl.is_comptime ||
- casted_arg->value->type->id == ZigTypeIdComptimeInt || casted_arg->value->type->id == ZigTypeIdComptimeFloat;
+ bool comptime_arg = param_decl_node->data.param_decl.is_comptime;
+ if (!comptime_arg) {
+ switch (type_requires_comptime(ira->codegen, casted_arg->value->type)) {
+ case ReqCompTimeInvalid:
+ return false;
+ case ReqCompTimeYes:
+ comptime_arg = true;
+ break;
+ case ReqCompTimeNo:
+ break;
+ }
+ }
ZigValue *arg_val;
@@ -17395,17 +17405,6 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod
}
if (!comptime_arg) {
- switch (type_requires_comptime(ira->codegen, casted_arg->value->type)) {
- case ReqCompTimeYes:
- ir_add_error(ira, casted_arg,
- buf_sprintf("parameter of type '%s' requires comptime", buf_ptr(&casted_arg->value->type->name)));
- return false;
- case ReqCompTimeInvalid:
- return false;
- case ReqCompTimeNo:
- break;
- }
-
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;