From 9433724bbd6efd4660de83f2ca450b7e61c007e9 Mon Sep 17 00:00:00 2001 From: water111 <48171810+water111@users.noreply.github.com> Date: Mon, 28 Jun 2021 20:34:13 -0400 Subject: [PATCH] another fix for forward declared types (#647) --- common/type_system/TypeSystem.cpp | 6 +++--- docs/markdown/progress-notes/changelog.md | 4 +++- goalc/compiler/compilation/Type.cpp | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/common/type_system/TypeSystem.cpp b/common/type_system/TypeSystem.cpp index fa630da465..b4036a40de 100644 --- a/common/type_system/TypeSystem.cpp +++ b/common/type_system/TypeSystem.cpp @@ -1353,14 +1353,14 @@ EnumType* TypeSystem::try_enum_lookup(const TypeSpec& type) const { * Get a path from type to object. */ std::vector TypeSystem::get_path_up_tree(const std::string& type) const { - auto parent = lookup_type(type)->get_parent(); + auto parent = lookup_type_allow_partial_def(type)->get_parent(); std::vector path = {type}; path.push_back(parent); - auto parent_type = lookup_type(parent); + auto parent_type = lookup_type_allow_partial_def(parent); while (parent_type->has_parent()) { parent = parent_type->get_parent(); - parent_type = lookup_type(parent); + parent_type = lookup_type_allow_partial_def(parent); path.push_back(parent); } diff --git a/docs/markdown/progress-notes/changelog.md b/docs/markdown/progress-notes/changelog.md index c6b8fab8d5..d9b32a5a76 100644 --- a/docs/markdown/progress-notes/changelog.md +++ b/docs/markdown/progress-notes/changelog.md @@ -168,4 +168,6 @@ - Added a `type-ref` form to insert a reference to a type into a static structure and optionally forward declare the number of methods - The `method-of-type` form will now accept an expression returning a type instead of just a type name. In this case, it will only allow you to access method of `object`. - Added a `defun-recursive` to make it easier to define recursive functions -- Forward declared basics can be used in more places \ No newline at end of file +- Forward declared basics can be used in more places +- You can now set a field which has a forward declared structure or basic type +- `cdr` now returns an object of type `pair`. \ No newline at end of file diff --git a/goalc/compiler/compilation/Type.cpp b/goalc/compiler/compilation/Type.cpp index aaf0ef931f..39504021c7 100644 --- a/goalc/compiler/compilation/Type.cpp +++ b/goalc/compiler/compilation/Type.cpp @@ -1093,7 +1093,7 @@ Val* Compiler::compile_cdr(const goos::Object& form, const goos::Object& rest, E if (pair->type() != m_ts.make_typespec("object")) { typecheck(form, m_ts.make_typespec("pair"), pair->type(), "Type of argument to cdr"); } - auto result = fe->alloc_val(m_ts.make_typespec("object"), pair, false); + auto result = fe->alloc_val(m_ts.make_typespec("pair"), pair, false); result->mark_as_settable(); return result; }