authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-04-07 00:33:19-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-04-07 00:33:19-04:00
logffb4852012509327c646c9899259e894965b2259
treec187efa334e090db5ff389b2e76a6dea33d3ffd6
parenta3de550d3bf020fd68e1331d3cb8b7b422894f96

add compile error for the bug of unable to call var ags at compile time

See #313

2 files changed, 8 insertions(+), 0 deletions(-)

src/ir.cpp+7
......@@ -8252,6 +8252,13 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
82528252 return ira->codegen->builtin_types.entry_invalid;
82538253 }
82548254
8255 if (fn_proto_node->data.fn_proto.is_var_args) {
8256 ir_add_error(ira, &call_instruction->base,
8257 buf_sprintf("compiler bug: unable to call var args function at compile time. https://github.com/andrewrk/zig/issues/313"));
8258 return ira->codegen->builtin_types.entry_invalid;
8259 }
8260
8261
82558262 for (size_t call_i = 0; call_i < call_instruction->arg_count; call_i += 1) {
82568263 IrInstruction *old_arg = call_instruction->args[call_i]->other;
82578264 if (type_is_invalid(old_arg->value.type))
test/cases/var_args.zig+1
......@@ -37,6 +37,7 @@ test "runtime parameter before var args" {
3737 assert(extraFn(10, false) == 1);
3838 assert(extraFn(10, false, true) == 2);
3939
40 // TODO issue #313
4041 //comptime {
4142 // assert(extraFn(10) == 0);
4243 // assert(extraFn(10, false) == 1);