polymorphic variables on compound types
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 12 Jan 2021 16:49:40 +0000 (10:49 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 12 Jan 2021 16:49:40 +0000 (10:49 -0600)
bin/onyx
misc/onyx.sublime-syntax
onyx.exe
src/onyxutils.c

index 795bdb46277a79c8275c3f06c4601ad027a21133..4d6e3d911cb5a7741d99a9d5383aa64f68144f2f 100755 (executable)
Binary files a/bin/onyx and b/bin/onyx differ
index 70ab16248b8683d2b941b90f553dd185c1391706..0a1a75780ddfdded4e61df7c4d2bfcab415b6d37 100644 (file)
@@ -67,9 +67,10 @@ contexts:
       captures:
         1: meta.function-call.onyx
 
-    - match: '([a-zA-Z_][a-zA-Z0-9_]*)\s*:'
+    - match: '([a-zA-Z_][a-zA-Z0-9_]*)(,\s*([a-zA-Z_][a-zA-Z0-9_]*))*\s*:'
       captures:
         1: variable
+        2: variable
 
   double_quoted_string:
     - meta_scope: string.quoted.double.onyx
index d254d18ef69973ad2b5f495dd6e9494860d50240..56839afc24d0e047aaac0a9b754a5cc20bd5439c 100644 (file)
Binary files a/onyx.exe and b/onyx.exe differ
index efd2a486ef8d77b8d86757f375c3e5a27ca08cfa..2fca21ddcb2e53665a30465e1fc52401d93b5208 100644 (file)
@@ -320,6 +320,23 @@ static PolySolveResult solve_poly_type(AstNode* target, AstType* type_expr, Type
                 break;
             }
 
+            case Ast_Kind_Type_Compound: {
+                if (elem.actual->kind != Type_Kind_Compound) break;
+                if (bh_arr_length(elem.actual->Compound.types) != bh_arr_length(((AstCompoundType *) elem.type_expr)->types)) break;
+
+                AstCompoundType* ct = (AstCompoundType *) elem.type_expr;
+
+                fori (i, 0, bh_arr_length(ct->types)) {
+                    bh_arr_push(elem_queue, ((PolySolveElem) {
+                        .kind = PSK_Type,
+                        .type_expr = ct->types[i],
+                        .actual = elem.actual->Compound.types[i],
+                    }));
+                }
+
+                break;
+            }
+
             default: break;
         }
     }