From 0975bff6ddcf48de4072561adea67a5c1cd4456f Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Thu, 14 Aug 2025 12:17:41 +0300 Subject: fix: step scrutinee of case & can instantiate empty vec --- src/type/check.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/type') 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 { 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())?; -- cgit v1.2.3