diff --git a/src/lang/interpreter.cc b/src/lang/interpreter.cc index 20fa825..0c32940 100644 --- a/src/lang/interpreter.cc +++ b/src/lang/interpreter.cc @@ -199,6 +199,18 @@ namespace verona::interpreter { std::string field{node->location().view()}; auto v = rt::get(frame(), field); + if (!v) + { + if (field == "True") + { + v = rt::get_true(); + } + else if (field == "False") + { + rt::get_false(); + } + } + rt::add_reference(frame(), v); stack().push_back(v); std::cout << "push " << v << std::endl; @@ -308,6 +320,7 @@ namespace verona::interpreter result = rt::get_false(); result_str = "false"; } + rt::add_reference(frame(), result); stack().push_back(result); std::cout << "push " << result << " (" << result_str << ")" << std::endl; @@ -326,6 +339,7 @@ namespace verona::interpreter { auto v = pop("jump condition"); auto jump = (v == rt::get_false()); + rt::remove_reference(frame(), v); if (jump) { return ExecJump{node->location()}; @@ -442,7 +456,9 @@ namespace verona::interpreter // Setup the new frame for (size_t i = 0; i < func.arg_ctn; i++) { - frame->stack.push_back(parent_frame->stack.back()); + auto value = parent_frame->stack.back(); + frame->stack.push_back(value); + rt::move_reference(parent_frame->frame, frame->frame, value); parent_frame->stack.pop_back(); } } diff --git a/tests/recursive_list.vpy b/tests/recursive_list.vpy index 11f4f28..8b9b03a 100644 --- a/tests/recursive_list.vpy +++ b/tests/recursive_list.vpy @@ -35,10 +35,18 @@ list = new_list() region list value = "x" + +# Dyrona doesn't freeze shared objects automatically (yet) +# There is currently a bug, where the LRC gets incorrect, if "[String]" isn't frozen +proto = value["__proto__"] +freeze proto +drop proto + insert(list.head, {}) insert(list.head, {}) insert(list.head, value) insert(list.head, {}) remove(list.head, value) +drop value drop list