From d64165e9e6af92bfe350e5d2cc46545b28dbb5c0 Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Tue, 5 Aug 2025 18:07:50 +0300 Subject: Added vectors and tests for their evaluation and typing --- src/type/check.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/type/check.rs') diff --git a/src/type/check.rs b/src/type/check.rs index c3bdcb4..10ef8b4 100644 --- a/src/type/check.rs +++ b/src/type/check.rs @@ -44,6 +44,20 @@ impl SExp { /// ); /// ``` /// + /// Vectors are kind of special... + /// ```rust + /// use myslip::{ + /// r#type::{*, Type::*, TypeError::*, util::*}, + /// sexp::{SExp::*, SLeaf::*, util::*}, + /// }; + /// + /// assert_eq!( + /// scons(Vector, scons(1, scons(3, Nil))).type_check(), + /// Ok(vecof(Integer)) + /// ); + /// ``` + /// ...so please don't ask what their type is. + /// /// Some common operators get arrow types: /// ```rust /// use myslip::{ @@ -109,6 +123,8 @@ impl SExp { /// assert!(scons(And, scons(1, scons(Atom(True), Nil))).type_check().is_err()); /// assert!(scons(Mul, scons(1, scons(Atom(True), Nil))).type_check().is_err()); /// assert!(scons(Not, scons(1, Nil)).type_check().is_err()); + /// + /// assert!(scons(Vector, scons(1, scons(True, Nil))).type_check().is_err()); /// ``` /// /// Also, free variables should result in an error @@ -153,6 +169,7 @@ impl SExp { vt("T"), List(vec![QuoteTy, vt("T")]) )), + Atom(Vector) => todo!(), SCons(op, l) => { let opertype = (*op).infer_type(ctx.clone())?; -- cgit v1.2.3