if (right_type->kind == Type_Kind_Compound) {
AstCompound* lhs = (AstCompound *) binop->left;
- if (lhs->kind != Ast_Kind_Compound) {
- ERROR_(binop->token->pos,
- "Expected left hand side to have %d expressions.",
- binop->right->type->Compound.count);
- }
-
i32 expr_count = right_type->Compound.count;
- if (bh_arr_length(lhs->exprs) != expr_count) {
- ERROR_(binop->token->pos,
- "Expected left hand side to have %d expressions.",
- binop->right->type->Compound.count);
+ if (lhs->kind != Ast_Kind_Compound || bh_arr_length(lhs->exprs) != expr_count) {
+ ERROR_(binop->token->pos, "Expected left hand side to have %d expressions.", expr_count);
}
- fori (i, 0, expr_count) {
- lhs->exprs[i]->type = right_type->Compound.types[i];
- }
+ fori (i, 0, expr_count) lhs->exprs[i]->type = right_type->Compound.types[i];
lhs->type = type_build_compound_type(context.ast_alloc, lhs);
}
if (local->type_node != NULL) CHECK(type, local->type_node);
- if (local->type_node != NULL) {
- if (!node_is_type((AstNode *) local->type_node)) {
- ERROR(local->token->pos, "Parameter type is not a type.");
- }
- }
fill_in_type((AstTyped *) local);
if (local->type == NULL) {
CheckStatus check_memres(AstMemRes* memres) {
if (memres->initial_value != NULL) {
if (memres->threadlocal) {
- onyx_report_error(memres->token->pos, "'#threadlocal' variables cannot have an initializer at the moment.");
+ onyx_report_error(memres->token->pos, "'#thread_local' variables cannot have an initializer at the moment.");
return Check_Error;
}
}
if ((memres->initial_value->flags & Ast_Flag_Comptime) == 0) {
+ if (memres->initial_value->entity != NULL && memres->initial_value->entity->state <= Entity_State_Check_Types) {
+ YIELD(memres->token->pos, "Waiting for initial value to be checked.");
+ }
+
ERROR(memres->initial_value->token->pos, "Top level expressions must be compile time known.");
}
}
// HACK HACK HACK
onyx_clear_errors();
- // onyx_report_error(constraint->interface->exprs[i]->token->pos, "This constraint was not satisfied.");
- // onyx_report_error(constraint->token->pos, "Here was where the interface was used.");
*constraint->report_status = Constraint_Check_Status_Failed;
return Check_Failed;
}
if (s_node->scope) scope_leave();
return ss;
}
-
- if (!node_is_type((AstNode *) member->type_node)) {
- onyx_report_error(member->token->pos, "Member type is not a type.");
- goto struct_symres_done;
- }
-
- if (member->is_used) {
- AstType *used = (AstType *) member->type_node;
-
- while (used->kind == Ast_Kind_Type_Alias) {
- used = ((AstTypeAlias *) used)->to;
- }
-
- b32 use_works = (used->kind == Ast_Kind_Struct_Type || used->kind == Ast_Kind_Poly_Call_Type);
-
- if (used->kind == Ast_Kind_Type_Raw_Alias) {
- AstTypeRawAlias* alias = (AstTypeRawAlias *) used;
- use_works = (alias->to->kind == Type_Kind_Struct);
- }
-
- if (!use_works) {
- onyx_report_error(member->token->pos,
- "Can only 'use' members of struct type, got '%s'.",
- onyx_ast_node_kind_string(used->kind));
- goto struct_symres_done;
- }
- }
}
}
}
static SymresStatus symres_directive_solidify(AstDirectiveSolidify** psolid) {
+ // @Cleanup: A lot of this code should move to the checker?
+
AstDirectiveSolidify* solid = *psolid;
if (solid->resolved_proc != NULL) {
*psolid = (AstDirectiveSolidify *) solid->resolved_proc;
bh_arr_each(AstPolySolution, sln, solid->known_polyvars) {
// HACK: This assumes that 'ast_type' and 'value' are at the same offset.
SYMRES(expression, &sln->value);
- if (onyx_has_errors()) return Symres_Error;
if (node_is_type((AstNode *) sln->value)) {
sln->type = type_build_from_ast(context.ast_alloc, sln->ast_type);
} else {
sln->kind = PSK_Value;
}
-
- if (onyx_has_errors()) return Symres_Error;
}
solid->resolved_proc = polymorphic_proc_try_solidify(solid->poly_proc, solid->known_polyvars, solid->token);
AstDirectiveDefined* defined = *pdefined;
b32 use_package_count = (context.entities.type_count[Entity_Type_Use_Package] == 0);
- b32 old_report_unresolved_symbols = report_unresolved_symbols;
- report_unresolved_symbols = 0;
SymresStatus ss = symres_expression(&defined->expr);
- if ((use_package_count || old_report_unresolved_symbols) && ss != Symres_Success) {
+ if (use_package_count && ss != Symres_Success) {
// The symbol definitely was not found and there is no chance that it could be found.
defined->is_defined = 0;
+ return Symres_Success;
+ }
- } else {
- if (ss == Symres_Success) {
- defined->is_defined = 1;
-
- } else {
- report_unresolved_symbols = old_report_unresolved_symbols;
- return Symres_Yield_Macro;
- }
+ if (ss == Symres_Success) {
+ defined->is_defined = 1;
+ return Symres_Success;
}
- report_unresolved_symbols = old_report_unresolved_symbols;
- return Symres_Success;
+ return Symres_Yield_Macro;
}
static SymresStatus symres_directive_insert(AstDirectiveInsert* insert) {
if (param->local->type_node != NULL && param->local->type == NULL) {
param->local->type = type_build_from_ast(context.ast_alloc, param->local->type_node);
- if (param->local->type == NULL) {
- // HACK HACK HACK
- scope_leave();
- return Symres_Yield_Macro;
- }
+ if (param->local->type == NULL) return Symres_Yield_Macro;
}
if (type_is_struct(param->local->type)) {
return Symres_Error;
}
- /*if (binop_is_assignment(operator->operator)) {
- onyx_report_error(overload->token->pos, "'%s' is not currently overloadable.", binaryop_string[operator->operator]);
- return Symres_Error;
- }*/
-
add_overload_option(&operator_overloads[operator->operator], 0, operator->overload);
break;
}
onyx_report_error(export->token->pos, "Cannot export an intrinsic function.");
return Symres_Error;
}
-
- // NOTE: This should never happen
- if (func->exported_name == NULL) {
- onyx_report_error(export->token->pos, "Cannot export function without a name.");
- return Symres_Error;
- }
}
}
if (ent->scope) scope_enter(ent->scope);
report_unresolved_symbols = context.cycle_detected;
- //(context.entities.type_count[Entity_Type_Static_If] == 0 &&
- // context.entities.type_count[Entity_Type_Use_Package] == 0)
- //|| context.cycle_detected;
SymresStatus ss = Symres_Success;
EntityState next_state = Entity_State_Check_Types;