diff --git a/compiler/typecheck/step3_function_and_method_bodies.jou b/compiler/typecheck/step3_function_and_method_bodies.jou index 595ea962..65ae2744 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 @@ -1017,7 +1024,7 @@ def typecheck_expression(ft: FileTypes*, expr: AstExpression*) -> None: do_explicit_cast(ft->current_fom_types, &expr->as_->value, result, expr->location) case _: - printf("%d\n", expr->kind) + printf("%d\n", expr->kind as int) assert False assert result != NULL 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