More type work
This commit is contained in:
parent
65c47c20fc
commit
e9b90412ce
@ -28,6 +28,7 @@ enum TConst {
|
|||||||
Int,
|
Int,
|
||||||
Float,
|
Float,
|
||||||
StringT,
|
StringT,
|
||||||
|
Bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TConst {
|
impl TConst {
|
||||||
@ -80,12 +81,17 @@ impl TypeContext {
|
|||||||
|
|
||||||
fn infer_expr_type(&mut self, expr_type: &ExpressionType) -> InferResult<MonoType> {
|
fn infer_expr_type(&mut self, expr_type: &ExpressionType) -> InferResult<MonoType> {
|
||||||
use self::ExpressionType::*;
|
use self::ExpressionType::*;
|
||||||
match expr_type {
|
Ok(match expr_type {
|
||||||
NatLiteral(_) => Ok(MonoType::Const(TConst::Nat)),
|
NatLiteral(_) => MonoType::Const(TConst::Nat),
|
||||||
FloatLiteral(_) => Ok(MonoType::Const(TConst::Float)),
|
FloatLiteral(_) => MonoType::Const(TConst::Float),
|
||||||
StringLiteral(_) => Ok(MonoType::Const(TConst::StringT)),
|
StringLiteral(_) => MonoType::Const(TConst::StringT),
|
||||||
_ => Ok(MonoType::Const(TConst::user("unimplemented")))
|
BoolLiteral(_) => MonoType::Const(TConst::Bool),
|
||||||
}
|
_ => MonoType::Const(TConst::user("unimplemented"))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn unify(t1: MonoType, t2: MonoType) -> InferResult<MonoType> {
|
||||||
|
unimplemented!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user