Skip to content

Commit

Permalink
add compile error for missing parameter name of generic function
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrk committed Jul 25, 2018
1 parent 8419546 commit fd575fe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ir.cpp
Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions test/compile_errors.zig
@@ -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 {
Expand Down

0 comments on commit fd575fe

Please sign in to comment.