maybe fixed array literals
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 12 Oct 2021 03:29:55 +0000 (22:29 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 12 Oct 2021 03:29:55 +0000 (22:29 -0500)
bin/onyx
src/astnodes.c
src/checker.c

index 00f961ef230241c11fd10ec491ce05c6733918f4..bda45c0752e60225246fc8beba439d53d567efcb 100755 (executable)
Binary files a/bin/onyx and b/bin/onyx differ
index 2117092b4cb2355bdb672290901e9f6508052ff0..2d1f1e8b514dea55166f43144f257667f8571496 100644 (file)
@@ -535,7 +535,21 @@ b32 unify_node_and_type_(AstTyped** pnode, Type* type, b32 permanent) {
         // just assume that it works and don't submit the entities.
         if (!permanent) return 1;
 
-        node->type = type;
+        Type* array_type=NULL;
+        switch (type->kind) {
+            case Type_Kind_Array: array_type = type; break;
+            case Type_Kind_Slice: {
+                Type* elem_type = type->Slice.elem;
+                AstArrayLiteral* al = (AstArrayLiteral *) node;
+                array_type = type_make_array(context.ast_alloc, elem_type, bh_arr_length(al->values));
+
+                break;
+            }
+
+            default: assert(0);
+        }
+
+        node->type = array_type;
         node->flags |= Ast_Flag_Array_Literal_Typed;
 
         add_entities_for_node(NULL, (AstNode *) node, NULL, NULL);
index 74b8b612dbcd52964211c1557ab17374b2ea3a8c..8b175999e5c000223e8a58171440fd4dd2a3ed43 100644 (file)
@@ -1115,8 +1115,8 @@ CheckStatus check_struct_literal(AstStructLiteral* sl) {
 CheckStatus check_array_literal(AstArrayLiteral* al) {
     // :Idempotency
     if ((al->flags & Ast_Flag_Array_Literal_Typed) == 0) {
-        if (al->atnode == NULL)
-            YIELD(al->token->pos, "Waiting for array literal type to be known.");
+        if (al->atnode == NULL) return Check_Success;
+            // YIELD(al->token->pos, "Waiting for array literal type to be known.");
 
         if (!node_is_type((AstNode *) al->atnode))
             ERROR(al->token->pos, "Array type is not a type.");