From d4c109b6ef5999b25dcd3f795df79c37fde9fff7 Mon Sep 17 00:00:00 2001 From: David Mak Date: Mon, 11 Dec 2023 12:33:43 +0800 Subject: [PATCH] core: Add missing generic constant concrete type --- nac3core/src/codegen/concrete_type.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/nac3core/src/codegen/concrete_type.rs b/nac3core/src/codegen/concrete_type.rs index 9181a1cad..472f78e1e 100644 --- a/nac3core/src/codegen/concrete_type.rs +++ b/nac3core/src/codegen/concrete_type.rs @@ -60,6 +60,10 @@ pub enum ConcreteTypeEnum { ret: ConcreteType, vars: HashMap, }, + TConstant { + value: SymbolValue, + ty: ConcreteType, + }, } impl ConcreteTypeStore { @@ -198,7 +202,11 @@ impl ConcreteTypeStore { TypeEnum::TFunc(signature) => { self.from_signature(unifier, primitives, signature, cache) } - _ => unreachable!(), + TypeEnum::TConstant { value, ty, .. } => ConcreteTypeEnum::TConstant { + value: value.clone(), + ty: self.from_unifier_type(unifier, primitives, *ty, cache), + }, + _ => unreachable!("{:?}", ty_enum.get_type_name()), }; let index = if let Some(ConcreteType(index)) = cache.get(&ty).unwrap() { self.store[*index] = result; @@ -285,6 +293,11 @@ impl ConcreteTypeStore { .map(|(id, cty)| (*id, self.to_unifier_type(unifier, primitives, *cty, cache))) .collect::>(), }), + ConcreteTypeEnum::TConstant { value, ty } => TypeEnum::TConstant { + value: value.clone(), + ty: self.to_unifier_type(unifier, primitives, *ty, cache), + loc: None, + } }; let result = unifier.add_ty(result); if let Some(ty) = cache.get(&cty).unwrap() {