From 183311b872406e1928851a29a953c07954653297 Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Mon, 18 Aug 2025 13:56:58 +0300 Subject: fix: refined [x] to x conversion, think (not true) and (vector 1) --- src/type/conversion.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/type/conversion.rs') diff --git a/src/type/conversion.rs b/src/type/conversion.rs index 844632f..ab858e6 100644 --- a/src/type/conversion.rs +++ b/src/type/conversion.rs @@ -12,6 +12,7 @@ impl Type { /// 1. (T T ... T T) -> (T ...) /// 2. self = concrete and other = variable type => self, /// 3. arrow types and lists are mapped + /// 4. makes [self] self if self == other pub fn convert(self, other: &Type) -> Result { let (ty, ctx) = self.convert_ctx(other)?; let mut checks = HashMap::new(); @@ -83,6 +84,12 @@ impl Type { Ok((vecof(convt), ctx)) }, + // at the end, because it'd be nice to know in the + // guard that the conversion from v to t2 works, and + // if it doesn't, try something else, but now everyhting + // has already been tried so this is safe + (List(v), t2) if v.len() == 1 => v[0].clone().convert_ctx(t2), + _ => Err(()) } } -- cgit v1.2.3