Have + do something different with strings
Needed to introduce polymorphism soon
This commit is contained in:
parent
200d0f9867
commit
ddd861fbea
@ -85,6 +85,7 @@ impl ReplState {
|
||||
let opstr: &str = &op.0;
|
||||
Ok(match (opstr, evaled_lhs, evaled_rhs) {
|
||||
("+", UnsignedInt(l), UnsignedInt(r)) => UnsignedInt(l + r),
|
||||
("+", Str(s1), Str(s2)) => Str(format!("{}{}", s1, s2)),
|
||||
("-", UnsignedInt(l), UnsignedInt(r)) => UnsignedInt(l - r),
|
||||
("*", UnsignedInt(l), UnsignedInt(r)) => UnsignedInt(l * r),
|
||||
("/", UnsignedInt(l), UnsignedInt(r)) => UnsignedInt(l / r),
|
||||
|
@ -214,10 +214,23 @@ impl TypeContext {
|
||||
})
|
||||
}
|
||||
|
||||
fn infer_op(&mut self, _op: &Operation) -> TypeCheckResult {
|
||||
fn infer_op(&mut self, op: &Operation) -> TypeCheckResult {
|
||||
use self::Type::*;
|
||||
use self::TypeConst::*;
|
||||
|
||||
let opstr: &str = &op.0;
|
||||
if opstr == "+" {
|
||||
return Ok(
|
||||
TConst(FunctionT(
|
||||
Box::new(TConst(StringT)),
|
||||
Box::new(TConst(FunctionT(
|
||||
Box::new(TConst(StringT)),
|
||||
Box::new(TConst(StringT))
|
||||
)))
|
||||
))
|
||||
)
|
||||
}
|
||||
|
||||
Ok(
|
||||
TConst(FunctionT(
|
||||
Box::new(TConst(Integer)),
|
||||
|
Loading…
Reference in New Issue
Block a user