Skip to content

Commit ffb4852

Browse files
committed
add compile error for the bug of unable to call var ags at compile time
See #313
1 parent a3de550 commit ffb4852

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/ir.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -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
Original file line numberDiff line numberDiff line change
@@ -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);

0 commit comments

Comments
 (0)