mirror of
https://github.com/edg-l/edlang.git
synced 2024-11-22 07:58:24 +00:00
fixes
This commit is contained in:
parent
bab8eec51f
commit
84e6cc630e
14
simple.ed
14
simple.ed
|
@ -7,12 +7,18 @@ fn test(x: Hello) {
|
|||
return;
|
||||
}
|
||||
|
||||
fn works(x: i32) -> i32 {
|
||||
return x * 4;
|
||||
fn works(x: i64) -> i64 {
|
||||
let z: i64 = 0;
|
||||
if x == 2 {
|
||||
z = x * 2;
|
||||
} else {
|
||||
z = x * 3;
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
fn main() -> i32 {
|
||||
let y = 2;
|
||||
fn main() -> i64 {
|
||||
let y: i64 = 2;
|
||||
let z = y;
|
||||
return works(z);
|
||||
}
|
||||
|
|
|
@ -295,7 +295,7 @@ impl<'ctx> CodeGen<'ctx> {
|
|||
self.functions.get(function).unwrap().clone().1
|
||||
}
|
||||
Expression::BinaryOp(lhs, op, rhs) => match op {
|
||||
OpCode::Eq | OpCode::Ne => Some(TypeExp::Boolean),
|
||||
//OpCode::Eq | OpCode::Ne => Some(TypeExp::Boolean),
|
||||
_ => self
|
||||
.find_expr_type(lhs, variables)
|
||||
.or_else(|| self.find_expr_type(rhs, variables)),
|
||||
|
@ -386,8 +386,9 @@ impl<'ctx> CodeGen<'ctx> {
|
|||
body,
|
||||
else_body,
|
||||
} => {
|
||||
let type_hint = self.find_expr_type(condition, variables);
|
||||
let (condition, _cond_type) = self
|
||||
.compile_expression(condition, variables, types, Some(TypeExp::Boolean))?
|
||||
.compile_expression(condition, variables, types, type_hint)?
|
||||
.expect("should produce a value");
|
||||
|
||||
let mut if_block = self.context.append_basic_block(function_value, "if");
|
||||
|
|
Loading…
Reference in a new issue