From 16daf6824ca72e81cd686483ab97ca7ac24c550a Mon Sep 17 00:00:00 2001 From: Vic Nightfall Date: Sat, 20 Apr 2024 23:15:07 +0200 Subject: [PATCH] Fix memory leak --- src/consteval.pr | 1 + src/scope.pr | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/consteval.pr b/src/consteval.pr index cdffde9d..9957e667 100644 --- a/src/consteval.pr +++ b/src/consteval.pr @@ -45,6 +45,7 @@ export def make_value(value: compiler::Value) -> &scope::Value { export def copy_state(state: &typechecking::State) -> &typechecking::State { let new_state: &typechecking::State = @state new_state.function_stack = vector::copy(state.function_stack) + new_state.context = null return new_state } diff --git a/src/scope.pr b/src/scope.pr index 62f1f45c..69f80490 100644 --- a/src/scope.pr +++ b/src/scope.pr @@ -1712,16 +1712,16 @@ export def create_polymorph( scope = scope.module.scope // Global scope let module_name = module.filename - let v = create_function_value(scope, name_node, parser::ShareMarker::NONE, Phase::COMPILED, node, state, tpe, impl) if not scope.polymorphics { scope.polymorphics = map::make(type &Scope) } var poly_scope = scope.polymorphics.get_or_default(module_name, null) if not poly_scope { - poly_scope = enter_scope(null, scope.module) + poly_scope = enter_scope(null, null) + scope.polymorphics(module_name) = poly_scope } - scope.polymorphics(module_name) = poly_scope + let v = create_function_value(scope, name_node, parser::ShareMarker::NONE, Phase::COMPILED, node, null, tpe, impl) return create_function(poly_scope, name_node, v, impl) }