if statement does not work with variables
Created by: msehnout
We need to handle variable names in conditions so we can compare them. The if statement implementation is pretty simple right now. Do you have any other idea what could be implemented and how to improve it?
Reproduction: Add debug message:
diff --git a/src/main.rs b/src/main.rs
index d614815..aa2d50a 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -260,6 +260,7 @@ impl Shell {
}
fn handle_if(&mut self, left: String, comparitor: Comparitor, right: String) {
+ println!("DBG: {:?} == {:?}", left, right);
let value = match comparitor {
Comparitor::GreaterThan => { left > right },
Comparitor::GreaterThanOrEqual => { left >= right },
Run this script:
let test=0
if $test == 0
echo pass
else
echo fail
end
Expected behavior: pass
Actual behavior: [describe the actual behavior, which is presented through the repro.].
cargo run examples/variable_number_comparison.ion
Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
Running `target/debug/ion examples/variable_number_comparison.ion`
DBG: "$test" == "0"
fail