From 38b7030e98cd49921e869110a901f9ee0a29410e Mon Sep 17 00:00:00 2001 From: sofia Date: Tue, 22 Jul 2025 22:55:44 +0300 Subject: [PATCH] Fix binary operations --- reid/src/codegen.rs | 2 +- reid_src/test.reid | 17 ++++++----------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/reid/src/codegen.rs b/reid/src/codegen.rs index afc0d85..671fa5d 100644 --- a/reid/src/codegen.rs +++ b/reid/src/codegen.rs @@ -672,7 +672,7 @@ impl mir::Expression { }; Some(StackValue( StackValueKind::Immutable(scope.block.build(instr).unwrap()), - TypeKind::U32, + lhs_type, )) } mir::ExprKind::FunctionCall(call) => { diff --git a/reid_src/test.reid b/reid_src/test.reid index 1c451e2..6120537 100644 --- a/reid_src/test.reid +++ b/reid_src/test.reid @@ -1,12 +1,7 @@ -fn vec_sub(l: [f32; 3], r: [f32; 3]) -> [f32; 3] { - return [l[0]-r[0], l[1]-r[1], l[2]-r[2]]; -} +fn foo() -> f32 { return 1.0; } -fn foo(x: f32) { - let a = [x, x, 0.0]; - let b = [x, x, x]; // works - // let b = [x * 0.5, x * 0.5, x]; // does not work - vec_sub(a, b); -} - -fn main() {} \ No newline at end of file +fn main() -> u8 { + let mut a = 0; + a = (foo() * 1.0) as u8; + return a; +} \ No newline at end of file