add compile error for missing parameter name of generic function

This commit is contained in:
Andrew Kelley 2018-07-25 18:15:55 -04:00
parent 84195467ad
commit fd575fe1f3
2 changed files with 12 additions and 0 deletions

View File

@ -12591,6 +12591,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod
}
Buf *param_name = param_decl_node->data.param_decl.name;
if (!param_name) return false;
if (!is_var_args) {
VariableTableEntry *var = add_variable(ira->codegen, param_decl_node,
*child_scope, param_name, true, arg_val, nullptr);

View File

@ -1,6 +1,17 @@
const tests = @import("tests.zig");
pub fn addCases(cases: *tests.CompileErrorContext) void {
cases.add(
"missing parameter name of generic function",
\\fn dump(var) void {}
\\export fn entry() void {
\\ var a: u8 = 9;
\\ dump(a);
\\}
,
".tmp_source.zig:1:9: error: missing parameter name",
);
cases.add(
"non-inline for loop on a type that requires comptime",
\\const Foo = struct {