//! > Test +=
//! > test_runner_name
test_expr_diagnostics(expect_diagnostics: false)
//! > expr_code
foo()
//! > module_code
fn foo() {
let mut x: felt252 = 3;
x += 4;
}
//! > function_body
//! > expected_diagnostics
//! > ==========================================================================
//! > Test += for non-variable
//! > test_runner_name
test_expr_diagnostics(expect_diagnostics: true)
//! > expr_code
foo()
//! > module_code
fn foo() {
4 += 4;
}
//! > function_body
//! > expected_diagnostics
error[E2079]: ref argument must be a variable.
--> lib.cairo:2:5
4 += 4;
^
//! > ==========================================================================
//! > Test += for non-mutable variable
//! > test_runner_name
test_expr_diagnostics(expect_diagnostics: true)
//! > expr_code
foo()
//! > module_code
fn foo() {
let x = 3;
x += 4;
}
//! > function_body
//! > expected_diagnostics
error[E2080]: ref argument must be a mutable variable.
--> lib.cairo:3:5
x += 4;
^
//! > ==========================================================================
//! > Test += for unsupported pair of types.
//! > test_runner_name
test_expr_diagnostics(expect_diagnostics: true)
//! > expr_code
foo()
//! > module_code
fn foo() {
let mut x = 3;
x += true;
}
//! > function_body
//! > expected_diagnostics
error[E2311]: Trait has no implementation in context: core::ops::arith::AddAssign::<core::felt252, core::bool>.
--> lib.cairo:3:5
x += true;
^^^^^^^^^
//! > ==========================================================================
//! > Test /= for an unsupported type.
//! > test_runner_name
test_expr_diagnostics(expect_diagnostics: true)
//! > expr_code
foo()
//! > module_code
fn foo() {
let mut x = true;
x /= false;
}
//! > function_body
//! > expected_diagnostics
error[E2311]: Trait has no implementation in context: core::ops::arith::DivAssign::<core::bool, core::bool>.
--> lib.cairo:3:5
x /= false;
^^^^^^^^^^