diff --git a/dust-lang/src/compiler.rs b/dust-lang/src/compiler.rs index e01d10d..5a34c95 100644 --- a/dust-lang/src/compiler.rs +++ b/dust-lang/src/compiler.rs @@ -150,9 +150,7 @@ impl<'src> Compiler<'src> { .iter() .rev() .find_map(|(instruction, _, _)| { - let is_get_local = matches!(instruction.operation(), Operation::GetLocal); - - if instruction.yields_value() && !is_get_local { + if instruction.yields_value() { Some(instruction.a() + 1) } else { None @@ -632,7 +630,11 @@ impl<'src> Compiler<'src> { let rule = ParseRule::from(&operator); let is_assignment = matches!( operator, - Token::PlusEqual | Token::MinusEqual | Token::StarEqual | Token::SlashEqual + Token::PlusEqual + | Token::MinusEqual + | Token::StarEqual + | Token::SlashEqual + | Token::PercentEqual ); if push_back_left { @@ -1729,7 +1731,7 @@ impl<'src> Compiler<'src> { ) -> Result<(), CompileError> { if matches!( (left, right), - (Type::Float, Type::Float) | (Type::Integer, Type::Integer) + (Type::Byte, Type::Byte) | (Type::Float, Type::Float) | (Type::Integer, Type::Integer) ) { Ok(()) } else { diff --git a/dust-lang/tests/math_add.rs b/dust-lang/tests/math_add.rs index 8a99948..a95ea81 100644 --- a/dust-lang/tests/math_add.rs +++ b/dust-lang/tests/math_add.rs @@ -120,10 +120,7 @@ fn add_character_and_string() { ), (Instruction::r#return(true), Span(9, 9)) ], - vec![ - ConcreteValue::Character('a'), - ConcreteValue::String("b".to_string()) - ], + vec![ConcreteValue::Character('a'), ConcreteValue::string("b")], vec![] )) ); @@ -287,8 +284,8 @@ fn add_strings() { (Instruction::r#return(true), Span(20, 20)) ], vec![ - ConcreteValue::String("Hello, ".to_string()), - ConcreteValue::String("world!".to_string()) + ConcreteValue::string("Hello, "), + ConcreteValue::string("world!") ], vec![] )) @@ -327,8 +324,5 @@ fn add_string_and_character() { )) ); - assert_eq!( - run(source), - Ok(Some(ConcreteValue::String("ab".to_string()))) - ); + assert_eq!(run(source), Ok(Some(ConcreteValue::string("ab")))); } diff --git a/dust-lang/tests/math_divide.rs b/dust-lang/tests/math_divide.rs index 8dfb1d2..f58eba4 100644 --- a/dust-lang/tests/math_divide.rs +++ b/dust-lang/tests/math_divide.rs @@ -18,9 +18,9 @@ fn divide_bytes() { Instruction::divide( Destination::Register(0), Argument::Constant(0), - Argument::Constant(0) + Argument::Constant(1) ), - Span(0, 7) + Span(5, 6) ), (Instruction::r#return(true), Span(11, 11)) ], diff --git a/dust-lang/tests/math_multiply.rs b/dust-lang/tests/math_multiply.rs index 4436d95..8d53537 100644 --- a/dust-lang/tests/math_multiply.rs +++ b/dust-lang/tests/math_multiply.rs @@ -18,13 +18,13 @@ fn multiply_floats() { Instruction::multiply( Destination::Register(0), Argument::Constant(0), - Argument::Constant(1) + Argument::Constant(0) ), Span(4, 5) ), (Instruction::r#return(true), Span(9, 9)), ], - vec![ConcreteValue::Float(2.0), ConcreteValue::Float(2.0)], + vec![ConcreteValue::Float(2.0)], vec![] )) );