From 61f8c5c825d74082266c135d0a575b5dc6f816d5 Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Fri, 31 Mar 2023 17:52:10 +0200 Subject: [PATCH] Removing polymorph from test --- base_data_structures.cpp | 1 + core_polymorph.cpp | 5 ++--- core_typechecking.cpp | 7 +++++++ examples/{polymorphism.core => _polymorphism.core} | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) rename examples/{polymorphism.core => _polymorphism.core} (96%) diff --git a/base_data_structures.cpp b/base_data_structures.cpp index 58d9748..a960789 100644 --- a/base_data_structures.cpp +++ b/base_data_structures.cpp @@ -485,6 +485,7 @@ int length(List *list) { template void free_all_nodes(List *list) { + if (list->first == 0) return; assert(!list->last->next); assert(!list->first->prev); list->last->next = list->first_free; diff --git a/core_polymorph.cpp b/core_polymorph.cpp index f191e93..894eda6 100644 --- a/core_polymorph.cpp +++ b/core_polymorph.cpp @@ -43,7 +43,7 @@ void next(Ast_Iter *iter) { For(node->decls) iter->stack.add(it); } break; - case AST_MODULE: invalid_codepath; break; + case AST_MODULE: break; // This happens when we import stuff case AST_FILE: invalid_codepath; break; case AST_IDENT: @@ -200,8 +200,7 @@ void next(Ast_Iter *iter) { case AST_LAMBDA_EXPR: { Ast_Lambda *node = (Ast_Lambda *)ast; iter->stack.add(node); - iter->stack.add(node->scope); - assert(node->scope); + if (node->scope) iter->stack.add(node->scope); For(node->ret) iter->stack.add(it); For(node->args) iter->stack.add(it); } break; diff --git a/core_typechecking.cpp b/core_typechecking.cpp index 15858f6..2dff168 100644 --- a/core_typechecking.cpp +++ b/core_typechecking.cpp @@ -938,6 +938,13 @@ try_resolving_lambda_scope(Operand *op, Ast_Lambda *lambda, Ast_Type *lambda_typ } *op = operand_lambda(lambda_type); + + // + // We remove all declarations to cleanup the scope + // for iteration + // + // If I want to implement :NestedDeclarations + // then probably this will need to get reverted free_all_nodes(&lambda->scope->decls); } else if (is_flag_set(lambda->flags, AST_FOREIGN)) { diff --git a/examples/polymorphism.core b/examples/_polymorphism.core similarity index 96% rename from examples/polymorphism.core rename to examples/_polymorphism.core index 3bcac37..6db866c 100644 --- a/examples/polymorphism.core +++ b/examples/_polymorphism.core @@ -25,6 +25,6 @@ Array :: struct($T: Type) cap: int main :: (argc: int, argv: **char): int - array: Array(int) + // array: Array(int) return 0 \ No newline at end of file