Fix old fibonacci not working due to last change
This commit is contained in:
parent
b19a32cd8a
commit
383302c1c2
@ -7,7 +7,6 @@ fn main() -> bool {
|
||||
fn fibonacci(value: u16) -> u16 {
|
||||
if value <= 2 {
|
||||
return 1;
|
||||
} else {
|
||||
return fibonacci(value - 1) + fibonacci(value - 2);
|
||||
};
|
||||
}
|
||||
fibonacci(value - 1) + fibonacci(value - 2)
|
||||
}
|
||||
|
@ -271,6 +271,7 @@ impl Expression {
|
||||
let res = else_block.typecheck(state, hint_t);
|
||||
state.or_else(res, Vague(Unknown), else_block.meta)
|
||||
} else {
|
||||
// TODO assert that then_ret_t is Void
|
||||
Vague(Unknown)
|
||||
};
|
||||
|
||||
|
@ -40,11 +40,12 @@ impl ReturnType for Expression {
|
||||
Variable(var) => var.return_type(),
|
||||
BinOp(_, then_e, else_e) => {
|
||||
let then_r = then_e.return_type()?;
|
||||
let else_e = else_e.return_type()?;
|
||||
let kind = if then_r.0 == ReturnKind::Hard && else_e.0 == ReturnKind::Hard {
|
||||
let else_r = else_e.return_type()?;
|
||||
|
||||
let kind = if then_r.0 == ReturnKind::Hard && else_r.0 == ReturnKind::Hard {
|
||||
ReturnKind::Hard
|
||||
} else {
|
||||
ReturnKind::Hard
|
||||
ReturnKind::Soft
|
||||
};
|
||||
Ok((kind, then_r.1))
|
||||
}
|
||||
@ -57,7 +58,20 @@ impl ReturnType for Expression {
|
||||
|
||||
impl ReturnType for IfExpression {
|
||||
fn return_type(&self) -> Result<(ReturnKind, TypeKind), ReturnTypeOther> {
|
||||
self.1.return_type()
|
||||
let then_r = self.1.return_type()?;
|
||||
if let Some(else_b) = &self.2 {
|
||||
let else_r = else_b.return_type()?;
|
||||
dbg!(&then_r, &else_r);
|
||||
|
||||
let kind = if then_r.0 == ReturnKind::Hard && else_r.0 == ReturnKind::Hard {
|
||||
ReturnKind::Hard
|
||||
} else {
|
||||
ReturnKind::Soft
|
||||
};
|
||||
Ok((kind, then_r.1))
|
||||
} else {
|
||||
Ok((ReturnKind::Soft, then_r.1))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user