From d41c923cfdc71979d5007a53cd3adad2798abe82 Mon Sep 17 00:00:00 2001 From: pca006132 Date: Mon, 28 Feb 2022 23:08:42 +0800 Subject: [PATCH] nac3artiq: handle recursive types properly --- nac3artiq/src/symbol_resolver.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nac3artiq/src/symbol_resolver.rs b/nac3artiq/src/symbol_resolver.rs index baf122c7d..0a79314cc 100644 --- a/nac3artiq/src/symbol_resolver.rs +++ b/nac3artiq/src/symbol_resolver.rs @@ -469,6 +469,10 @@ impl InnerResolver { primitives: &PrimitiveStore, ) -> PyResult> { let ty = self.helper.type_fn.call1(py, (obj,)).unwrap(); + let ty_id: u64 = self.helper.id_fn.call1(py, (ty.clone(),))?.extract(py)?; + if let Some(ty) = self.pyid_to_type.read().get(&ty_id) { + return Ok(Ok(*ty)) + } let (extracted_ty, inst_check) = match self.get_pyty_obj_type( py, { @@ -527,6 +531,7 @@ impl InnerResolver { Ok(types.map(|types| unifier.add_ty(TypeEnum::TTuple { ty: types }))) } (TypeEnum::TObj { params, fields, .. }, false) => { + self.pyid_to_type.write().insert(ty_id, extracted_ty); let var_map = params .iter() .map(|(id_var, ty)| {