From ede3706ca8f1c1606117b5a6507fc595157afba3 Mon Sep 17 00:00:00 2001 From: pca006132 Date: Mon, 21 Feb 2022 18:41:42 +0800 Subject: [PATCH] type_inferencer: special case tuple index error message --- nac3core/src/typecheck/type_inferencer/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nac3core/src/typecheck/type_inferencer/mod.rs b/nac3core/src/typecheck/type_inferencer/mod.rs index 9762fe04..4abcb9d0 100644 --- a/nac3core/src/typecheck/type_inferencer/mod.rs +++ b/nac3core/src/typecheck/type_inferencer/mod.rs @@ -1028,6 +1028,10 @@ impl<'a> Inferencer<'a> { Ok(ty) } _ => { + if let TypeEnum::TTuple { .. } = &*self.unifier.get_ty(value.custom.unwrap()) + { + return report_error("Tuple index must be a constant (KernelInvariant is also not supported)", slice.location) + } // the index is not a constant, so value can only be a list self.constrain(slice.custom.unwrap(), self.primitives.int32, &slice.location)?; let list = self.unifier.add_ty(TypeEnum::TList { ty });