Ast_Flag_From_Polymorphism = BH_BIT(23),
Ast_Flag_Incomplete_Body = BH_BIT(24),
+
+ Ast_Flag_Array_Literal_Typed = BH_BIT(25),
} AstFlags;
typedef enum UnaryOp {
return 1;
}
+ if (node->kind == Ast_Kind_Array_Literal && node->type_node == NULL) {
+ i32 value_count = bh_arr_length(((AstArrayLiteral *) node)->values);
+ node->type = type; // type_make_array(context.ast_alloc, type, value_count);
+ node->flags |= Ast_Flag_Array_Literal_Typed;
+
+ add_entities_for_node(NULL, (AstNode *) node, NULL, NULL);
+ return 1;
+ }
+
if (node->kind == Ast_Kind_Polymorphic_Proc) {
AstFunction* func = polymorphic_proc_lookup((AstPolyProc *) node, PPLM_By_Function_Type, type, node->token);
if (func == NULL) return 0;
}
CheckStatus check_array_literal(AstArrayLiteral* al) {
- if (!node_is_type((AstNode *) al->atnode)) {
- onyx_report_error(al->token->pos, "Array type is not a type.");
- return Check_Error;
- }
+ if ((al->flags & Ast_Flag_Array_Literal_Typed) == 0) {
+ if (al->atnode == NULL) return Check_Success;
- fill_in_type((AstTyped *) al);
+ if (!node_is_type((AstNode *) al->atnode)) {
+ onyx_report_error(al->token->pos, "Array type is not a type.");
+ return Check_Error;
+ }
- al->type = type_make_array(context.ast_alloc, al->type, bh_arr_length(al->values));
- if (al->type == NULL || al->type->kind != Type_Kind_Array) {
- onyx_report_error(al->token->pos, "Expected array type for array literal. This is a compiler bug.");
- return Check_Error;
+ fill_in_type((AstTyped *) al);
+ if (al->type == NULL) return Check_Error;
+
+ al->type = type_make_array(context.ast_alloc, al->type, bh_arr_length(al->values));
+ if (al->type == NULL || al->type->kind != Type_Kind_Array) {
+ onyx_report_error(al->token->pos, "Expected array type for array literal. This is a compiler bug.");
+ return Check_Error;
+ }
+
+ al->flags |= Ast_Flag_Array_Literal_Typed;
}
if (al->type->Array.count != (u32) bh_arr_length(al->values)) {
SYMRES(type, (AstType **) &al->atnode);
al->type_node = (AstType *) al->atnode;
- while (al->type_node->kind == Ast_Kind_Type_Alias)
+ while (al->type_node && al->type_node->kind == Ast_Kind_Type_Alias)
al->type_node = ((AstTypeAlias *) al->type_node)->to;
bh_arr_each(AstTyped *, expr, al->values)