diff options
author | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-08-14 12:17:41 +0300 |
---|---|---|
committer | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-08-14 12:17:41 +0300 |
commit | 0975bff6ddcf48de4072561adea67a5c1cd4456f (patch) | |
tree | f77291d0430079d6927bf896c133e97a6e59c684 /src/type | |
parent | 189d06730ae23770fbb970bf37eb0993edb8cd2d (diff) | |
download | myslip-0975bff6ddcf48de4072561adea67a5c1cd4456f.tar.gz myslip-0975bff6ddcf48de4072561adea67a5c1cd4456f.zip |
fix: step scrutinee of case & can instantiate empty vec
Diffstat (limited to 'src/type')
-rw-r--r-- | src/type/check.rs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/type/check.rs b/src/type/check.rs index f842b4c..02b629c 100644 --- a/src/type/check.rs +++ b/src/type/check.rs @@ -218,10 +218,10 @@ impl SExp { pub fn type_check(&self) -> Result<Type, TypeError> { let res = self.infer_type(HashMap::new()); match res { - Ok(res) => match res.is_concrete() { + Ok(res) => {println!("maybe unbound: {}", res); match res.is_concrete() { Ok(()) => Ok(res), Err(name) => Err(UnboundGeneric(name)), - }, + }}, e => e, } } @@ -281,6 +281,17 @@ impl SExp { return scons(op.clone(), l.clone()).get_fun_type(ctx); } + // Nil vector + if (**op).clone() == Atom(Nil) { + return match (**l).clone() { + SCons(v, n) if *n == Atom(Nil) => match *v { + Atom(Ty(t)) => Ok(vecof(t)), + _ => Err(OtherError), + }, + _ => Err(OtherError) + } + } + // Case expressions if let Some((scrutinee, patarms)) = scons(op.clone(), l.clone()).check_case() { let scruty = scrutinee.infer_type(ctx.clone())?; |