type_inferencer: special case tuple index error message

This commit is contained in:
pca006132 2022-02-21 18:41:42 +08:00
parent f97f93d92c
commit ede3706ca8
1 changed files with 4 additions and 0 deletions

View File

@ -1028,6 +1028,10 @@ impl<'a> Inferencer<'a> {
Ok(ty) 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 // the index is not a constant, so value can only be a list
self.constrain(slice.custom.unwrap(), self.primitives.int32, &slice.location)?; self.constrain(slice.custom.unwrap(), self.primitives.int32, &slice.location)?;
let list = self.unifier.add_ty(TypeEnum::TList { ty }); let list = self.unifier.add_ty(TypeEnum::TList { ty });