//! > Test struct snapshot.
//! > test_runner_name
test_function_diagnostics
//! > function_code
fn foo(a: @A) {
bar(a.a, a.b);
}
//! > function_name
foo
//! > module_code
struct A {
a: Array<felt252>,
b: felt252,
}
fn bar(a: @Array::<felt252>, b: @felt252) {}
//! > expected_diagnostics
//! > ==========================================================================
//! > Test coercion failure.
//! > test_runner_name
test_function_diagnostics(expect_diagnostics: true)
//! > function_code
fn foo() {
let _x: @felt252 = 5;
let _y: felt252 = @6;
}
//! > function_name
foo
//! > expected_diagnostics
error[E2041]: Unexpected argument type. Expected: "core::felt252", found: "@?1".
It is possible that the type inference failed because the types differ in the number of snapshots.
Consider adding or removing snapshots.
--> lib.cairo:3:23
let _y: felt252 = @6;
^^
//! > ==========================================================================
//! > Test coercion failure - no inference.
//! > test_runner_name
test_function_diagnostics(expect_diagnostics: true)
//! > function_code
fn foo() {
let _x: @felt252 = 5_felt252;
let _y: felt252 = @6_felt252;
}
//! > function_name
foo
//! > expected_diagnostics
error[E2041]: Unexpected argument type. Expected: "@core::felt252", found: "core::felt252".
--> lib.cairo:2:24
let _x: @felt252 = 5_felt252;
^^^^^^^^^
error[E2041]: Unexpected argument type. Expected: "core::felt252", found: "@core::felt252".
--> lib.cairo:3:23
let _y: felt252 = @6_felt252;
^^^^^^^^^^
//! > ==========================================================================
//! > Test struct snapshot auto member access desnap.
//! > test_runner_name
test_function_diagnostics
//! > crate_settings
edition = "2025_12"
//! > function_code
fn foo(a: @A) {
let _: @Array<felt252> = @a.a;
let _: @Array<felt252> = @(@a).a;
let _: @@Array<felt252> = @@(@a).a;
let _: felt252 = a.b;
let _: @felt252 = @a.b;
let _: @felt252 = @(@a).b;
let _: @@felt252 = @@(@a).b;
}
//! > function_name
foo
//! > module_code
struct A {
a: Array<felt252>,
b: felt252,
}
//! > expected_diagnostics