String types

This commit is contained in:
greg 2017-10-09 11:42:53 -07:00
parent 66c7bbeb07
commit 76a9367284

View File

@ -111,6 +111,7 @@ pub enum TypeVariable {
pub enum UVar { pub enum UVar {
Integer, Integer,
Float, Float,
String,
Boolean, Boolean,
Unit, Unit,
Function(Box<TypeVariable>, Box<TypeVariable>), Function(Box<TypeVariable>, Box<TypeVariable>),
@ -163,6 +164,7 @@ impl TypeContext {
}, },
(&IntLiteral(_), _) => Univ(UVar::Integer), (&IntLiteral(_), _) => Univ(UVar::Integer),
(&FloatLiteral(_), _) => Univ(UVar::Float), (&FloatLiteral(_), _) => Univ(UVar::Float),
(&StringLiteral(_), _) => Univ(UVar::String),
(&BoolLiteral(_), _) => Univ(UVar::Boolean), (&BoolLiteral(_), _) => Univ(UVar::Boolean),
(&Variable(ref name), _) => self.lookup(name).map(|entry| entry.type_var) (&Variable(ref name), _) => self.lookup(name).map(|entry| entry.type_var)
.ok_or(format!("Couldn't find {}", name))?, .ok_or(format!("Couldn't find {}", name))?,