diff --git a/compiler/typecheck/step3_function_and_method_bodies.jou b/compiler/typecheck/step3_function_and_method_bodies.jou index 595ea962..b825ce9a 100644 --- a/compiler/typecheck/step3_function_and_method_bodies.jou +++ b/compiler/typecheck/step3_function_and_method_bodies.jou @@ -623,6 +623,13 @@ def typecheck_function_or_method_call(ft: FileTypes*, call: AstCall*, self_type: do_implicit_cast(ft->current_fom_types, &call->args[i], intType, Location{}, NULL) elif t == floatType: do_implicit_cast(ft->current_fom_types, &call->args[i], doubleType, Location{}, NULL) + elif t->kind == TypeKind.Enum: + snprintf( + msg, sizeof(msg), + "enums cannot be passed to functions that take variadic arguments, such as %s", + sig->name, + ) + fail(call->args[i].location, msg) free(sigstr) return sig->returntype diff --git a/tests/wrong_type/enum_as_vararg.jou b/tests/wrong_type/enum_as_vararg.jou new file mode 100644 index 00000000..539c29a8 --- /dev/null +++ b/tests/wrong_type/enum_as_vararg.jou @@ -0,0 +1,9 @@ +import "stdlib/io.jou" + +enum Foo: + Bar + Baz + +def main() -> int: + printf("%d\n", Foo.Bar) # Error: enums cannot be passed to functions that take variadic arguments, such as printf + return 0