cleanup notes

This commit is contained in:
Krzosa Karol
2023-03-29 21:35:53 +02:00
parent 000cc7a813
commit 58a46b46e6

View File

@@ -874,6 +874,9 @@ parse_decl(B32 is_global) {
Ast_Expr *expr = parse_expr(); Ast_Expr *expr = parse_expr();
result = ast_const(tname, tname->intern_val, expr); result = ast_const(tname, tname->intern_val, expr);
// @cleanup: consider simplifying lambdas, removing AST_LAMBDA_EXPR and
// implementing actual parse_lambda or something. Probably needs less
// ambigious syntax.
if (expr->kind == AST_LAMBDA_EXPR) { if (expr->kind == AST_LAMBDA_EXPR) {
auto a = (Ast_Lambda *)expr; auto a = (Ast_Lambda *)expr;
if (a->scope || is_flag_set(flags, AST_FOREIGN)) { if (a->scope || is_flag_set(flags, AST_FOREIGN)) {
@@ -885,6 +888,10 @@ parse_decl(B32 is_global) {
} }
} }
else if (token_match(TK_StringLit, TK_DoubleColon)) { else if (token_match(TK_StringLit, TK_DoubleColon)) {
// @cleanup: consider simplifying lambdas, removing AST_LAMBDA_EXPR and
// implementing actual parse_lambda or something. Probably needs less
// ambigious syntax.
Ast_Lambda *expr = (Ast_Lambda *)parse_expr(); Ast_Lambda *expr = (Ast_Lambda *)parse_expr();
if (expr->kind != AST_LAMBDA_EXPR) { if (expr->kind != AST_LAMBDA_EXPR) {
compiler_error(tname, "Operator overload is required to be a lambda function"); compiler_error(tname, "Operator overload is required to be a lambda function");