aboutsummaryrefslogtreecommitdiff
path: root/src/analyze.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-07-24 10:13:40 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-07-24 10:21:33 -0400
commit29e19ace362e7a1910b9f105257f2bce2491e32b (patch)
treeedfd46e86405f4ba646b2c1d46566ad4dc9a92e4 /src/analyze.cpp
parent74c80d2c7fd370e6c1c588b06a3875effed9f388 (diff)
downloadzig-29e19ace362e7a1910b9f105257f2bce2491e32b.tar.gz
zig-29e19ace362e7a1910b9f105257f2bce2491e32b.zip
fix logic for determining whether param requires comptime
closes #778 closes #1213
Diffstat (limited to 'src/analyze.cpp')
-rw-r--r--src/analyze.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp
index 6bbe5f6037..f399ab8305 100644
--- a/src/analyze.cpp
+++ b/src/analyze.cpp
@@ -1585,10 +1585,6 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c
case TypeTableEntryIdBlock:
case TypeTableEntryIdBoundFn:
case TypeTableEntryIdMetaType:
- add_node_error(g, param_node->data.param_decl.type,
- buf_sprintf("parameter of type '%s' must be declared comptime",
- buf_ptr(&type_entry->name)));
- return g->builtin_types.entry_invalid;
case TypeTableEntryIdVoid:
case TypeTableEntryIdBool:
case TypeTableEntryIdInt:
@@ -1603,6 +1599,13 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c
case TypeTableEntryIdUnion:
case TypeTableEntryIdFn:
case TypeTableEntryIdPromise:
+ type_ensure_zero_bits_known(g, type_entry);
+ if (type_requires_comptime(type_entry)) {
+ add_node_error(g, param_node->data.param_decl.type,
+ buf_sprintf("parameter of type '%s' must be declared comptime",
+ buf_ptr(&type_entry->name)));
+ return g->builtin_types.entry_invalid;
+ }
break;
}
FnTypeParamInfo *param_info = &fn_type_id.param_info[fn_type_id.next_param_index];
@@ -5019,9 +5022,10 @@ bool type_requires_comptime(TypeTableEntry *type_entry) {
} else {
return type_requires_comptime(type_entry->data.pointer.child_type);
}
+ case TypeTableEntryIdFn:
+ return type_entry->data.fn.is_generic;
case TypeTableEntryIdEnum:
case TypeTableEntryIdErrorSet:
- case TypeTableEntryIdFn:
case TypeTableEntryIdBool:
case TypeTableEntryIdInt:
case TypeTableEntryIdFloat: