diff options
author | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-08-18 13:56:58 +0300 |
---|---|---|
committer | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-08-18 13:56:58 +0300 |
commit | 183311b872406e1928851a29a953c07954653297 (patch) | |
tree | c636bcbc40c3ff22ae2a74a9cafd625ecc1e0267 /src/type/conversion.rs | |
parent | 6ce77dfc296c24d43ac1e3b2daffec0a7e485891 (diff) | |
download | myslip-183311b872406e1928851a29a953c07954653297.tar.gz myslip-183311b872406e1928851a29a953c07954653297.zip |
fix: refined [x] to x conversion, think (not true) and (vector 1)
Diffstat (limited to 'src/type/conversion.rs')
-rw-r--r-- | src/type/conversion.rs | 7 |
1 files changed, 7 insertions, 0 deletions
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<Type, ()> { 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(()) } } |