use package printing
-call_me :: proc (f: proc (i32), val: i32) {
+call_me :: proc (f: proc (i32) -> i32, val: i32) {
f(val);
}
return func(left, right);
}
+echo :: proc (i: i32) -> i32 {
+ print(i);
+ return i;
+}
+
proc #export "main" {
- call_me(print_i32, 10);
+ call_me(echo, 10);
+
+ print(add as i32);
funcs[0] = add;
funcs[1] = sub;
while (actual_param != NULL) {
if (check_expression((AstTyped **) &actual_param)) return 1;
+ if (actual_param->value->kind == Ast_Kind_Overloaded_Function) {
+ onyx_message_add(Msg_Type_Literal,
+ actual_param->token->pos,
+ "cannot pass overloaded functions as parameters.");
+ return 1;
+ }
+
// NOTE: Splat structures into multiple arguments
if (actual_param->type->kind == Type_Kind_Struct) {
if (!type_struct_is_simple(actual_param->type)) {
if (t2->kind != Type_Kind_Function) return 0;
if (t1->Function.param_count != t2->Function.param_count) return 0;
+ if (!types_are_compatible(t1->Function.return_type, t2->Function.return_type)) return 0;
+
fori (i, 0, t1->Function.param_count - 1) {
if (!types_are_compatible(t1->Function.params[i], t2->Function.params[i])) return 0;
}
return;
}
+ if (to->kind == Type_Kind_Function) {
+ onyx_message_add(Msg_Type_Literal,
+ cast->token->pos,
+ "cannot cast to a function");
+ WI(WI_DROP);
+ return;
+ }
+
if (to->kind == Type_Kind_Basic && to->Basic.kind == Basic_Kind_Void) {
WI(WI_DROP);
return;