//! > Test for break with value
//! > test_runner_name
test_function_diagnostics(expect_diagnostics: true)
//! > function_code
fn foo() {
let mut _iter = array![10, 11, 12, 13_felt252].span();
for _x in _iter {
1;
break 5;
break;
}
}
//! > function_name
foo
//! > expected_diagnostics
error[E2147]: Can only break with a value inside a `loop`.
--> lib.cairo:5:9
break 5;
^^^^^^^^
//! > ==========================================================================
//! > Test for Unsupported feature
//! > test_runner_name
test_function_diagnostics(expect_diagnostics: true)
//! > function_code
fn foo() {
let arr = array![A { x: Some(1) }, A { x: None }, A { x: Some(2) }].span();
for A(x) in arr {
x;
}
}
//! > function_name
foo
//! > module_code
struct A {
x: Option<i32>,
}
//! > expected_diagnostics
error[E2009]: Not a variant. Use the full name Enum::Variant.
--> lib.cairo:6:9
for A(x) in arr {
^
error[E0006]: Identifier not found.
--> lib.cairo:7:9
x;
^
//! > ==========================================================================
//! > Test for loop with duplicate variables in pattern.
//! > test_runner_name
test_function_diagnostics(expect_diagnostics: true)
//! > function_code
fn foo() {
for (_a, _a) in array![(1, 2)] {}
}
//! > function_name
foo
//! > expected_diagnostics
error[E2049]: Redefinition of variable name "_a" in pattern.
--> lib.cairo:2:14
for (_a, _a) in array![(1, 2)] {}
^^