diff --git a/lambdas.kl b/lambdas.kl index 2d1d521..386e21d 100644 --- a/lambdas.kl +++ b/lambdas.kl @@ -25,11 +25,14 @@ add_10 :: (size: int): int constant :: 20; result := constant + 10 - v5 := add([0] = 1, [1] = 2) v1 := add(a = 1) v2 := add(a = 1, b = 2) v3 := add([0] = 1) v4 := add(b = 1, a = 2) + v5 := add([0] = 1, [1] = 2) + // v_err := add([0] = 1, 10) // illegal + // v_err := add([1] = 1) // illegal + // v_err := add() // illegal return v3 diff --git a/main.cpp b/main.cpp index 31052da..632ae60 100644 --- a/main.cpp +++ b/main.cpp @@ -65,8 +65,8 @@ int main(){ String result = {}; // result = compile_file("order1.kl"_s); - result = compile_file("lambdas.kl"_s); - // result = compile_file("order2.kl"_s); + // result = compile_file("lambdas.kl"_s); + result = compile_file("order2.kl"_s); // result = compile_file("globals.kl"_s); printf("%s", result.str); diff --git a/new_resolve.cpp b/new_resolve.cpp index 627574c..7308fb4 100644 --- a/new_resolve.cpp +++ b/new_resolve.cpp @@ -391,6 +391,7 @@ resolve_expr(Ast_Expr *ast, Ast_Resolved_Type *expected_type, Sym *const_sym){ Ast_Resolved_Type *resolved = type->func.args[i]; Ast_Lambda_Arg *arg = it[0]; + // @note: match any in list of call items, if none matched then we have a problem // there are three kinds of possible matches: indexed, named, default S64 default_iter = 0; @@ -411,10 +412,12 @@ resolve_expr(Ast_Expr *ast, Ast_Resolved_Type *expected_type, Sym *const_sym){ if(op.int_val == i) item = expr[0]; } else if(node->exprs.get_index(expr) == default_iter){ - // @todo might feel janky default_iter++; item = expr[0]; } + else{ + parsing_error(expr[0]->pos, "Positional argument after named or indexed argument"); + } if(item) break; } @@ -642,7 +645,7 @@ parse_file(){ sym->kind = SYM_CONST; Ast_Struct *s = const_try_getting_struct(decl); if(s){ - s->type = type_incomplete(decl); + s->type = type_incomplete(s); sym->type_val = s->type; sym->type = type_type; sym->state = SYM_RESOLVED; diff --git a/order2.kl b/order2.kl index 6a4ce73..d31e666 100644 --- a/order2.kl +++ b/order2.kl @@ -21,4 +21,10 @@ with_type: Arena = thing pointer := &with_type deref := *pointer +arena := Arena( + next = 0, + data = 0, + len = 1000, + cap = 1000, +)