forked from M-Labs/nac3
1
0
Fork 0

nac3artiq: handle recursive types properly

This commit is contained in:
pca006132 2022-02-28 23:08:42 +08:00
parent 5d8e87d923
commit d41c923cfd
1 changed files with 5 additions and 0 deletions

View File

@ -469,6 +469,10 @@ impl InnerResolver {
primitives: &PrimitiveStore,
) -> PyResult<Result<Type, String>> {
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)| {