static void __glfw_##callback_name (GLFWwindow *window, _EXPAND c_args) { \
wasm_val_t args[] = { WASM_I64_VAL((unsigned long long) window), _EXPAND wasm_args }; \
wasm_val_vec_t args_array = WASM_ARRAY_VEC(args); \
- wasm_val_vec_t results; \
+ wasm_val_vec_t results = WASM_EMPTY_VEC; \
runtime->wasm_func_call(__glfw_callback_##callback_name , &args_array, &results); \
} \
ONYX_DEF(callback_name, (LONG, PTR, INT), ()) { \
static void __glfw_##callback_name (GLFWwindow *window, _EXPAND c_args) { \
wasm_val_t args[] = { WASM_I64_VAL((unsigned long long) window), _EXPAND wasm_args }; \
wasm_val_vec_t args_array = WASM_ARRAY_VEC(args); \
- wasm_val_vec_t results; \
+ wasm_val_vec_t results = WASM_EMPTY_VEC; \
runtime->wasm_func_call(__glfw_callback_##callback_name , &args_array, &results); \
} \
ONYX_DEF(callback_name, (LONG, PTR, INT), ()) { \
b32 expect_default_param = 0;
b32 has_had_varargs = 0;
+ if (func->constraints.constraints != NULL && func->constraints.constraints_met == 0) {
+ func->constraints.produce_errors = (func->flags & Ast_Flag_Header_Check_No_Error) == 0;
+ CHECK(constraint_context, &func->constraints, func->scope, func->token->pos);
+
+ // All constraints have been met. Return to symbol resolution to finish
+ // looking up all symbols in the function.
+ return Check_Return_To_Symres;
+ }
+
bh_arr_each(AstParam, param, func->params) {
AstLocal* local = param->local;
if (func->return_type != NULL) CHECK(type, &func->return_type);
- if (func->constraints.constraints != NULL) {
- func->constraints.produce_errors = (func->flags & Ast_Flag_Header_Check_No_Error) == 0;
- CHECK(constraint_context, &func->constraints, func->scope, func->token->pos);
- }
-
func->type = type_build_function_type(context.ast_alloc, func);
if (func->type == NULL) YIELD(func->token->pos, "Waiting for function type to be constructed");
scope_enter(func->scope);
+ if (func->constraints.constraints != NULL && func->constraints.constraints_met == 0) {
+ bh_arr_each(AstConstraint *, constraint, func->constraints.constraints) {
+ SYMRES(constraint, *constraint);
+ }
+
+ // Return early here to finish checking constraints in the checker.
+ // Will resume here after constraints have been met.
+ return Symres_Success;
+ }
+
bh_arr_each(AstParam, param, func->params) {
if (param->default_value != NULL) {
SYMRES(expression, ¶m->default_value);
return Symres_Complete;
}
- if (func->nodes_that_need_entities_after_clone && bh_arr_length(func->nodes_that_need_entities_after_clone) > 0) {
+ if (func->nodes_that_need_entities_after_clone && bh_arr_length(func->nodes_that_need_entities_after_clone) > 0 && func->entity) {
bh_arr_each(AstNode *, node, func->nodes_that_need_entities_after_clone) {
// This makes a lot of assumptions about how these nodes are being processed,
// and I don't want to start using this with other nodes without considering
SYMRES(type, &func->return_type);
- if (func->constraints.constraints != NULL) {
- bh_arr_each(AstConstraint *, constraint, func->constraints.constraints) {
- SYMRES(constraint, *constraint);
- }
- }
-
scope_leave();
return Symres_Success;