//! > Test struct constructor.

//! > test_function_name
test_function_lowering

//! > function
fn foo(a: felt) -> MyStruct {
    MyStruct{a: (), c: (3, 7), b: a}
}

//! > function_name
foo

//! > module_code
struct MyStruct {
  a: (),
  b: felt,
  c: (felt, felt),
}

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_format
blk0 (root):
Inputs: v0: core::felt
Statements:
  (v1: ()) <- struct_construct()
  (v2: core::felt) <- 3u
  (v3: core::felt) <- 7u
  (v4: (core::felt, core::felt)) <- struct_construct(v2, v3)
  (v5: test::MyStruct) <- struct_construct(v1, v0, v4)
Drops: v0, v1, v2, v3, v4
End:
  Callsite(v5)

//! > ==========================================================================

//! > Test struct member access.

//! > test_function_name
test_function_lowering

//! > function
fn foo(s: MyStruct) -> felt {
    s.b
}

//! > function_name
foo

//! > module_code
struct MyStruct {
  a: (),
  b: felt,
  c: (felt, felt),
}

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_format
blk0 (root):
Inputs: v0: test::MyStruct
Statements:
  (v1: (), v2: core::felt, v3: (core::felt, core::felt)) <- struct_destructure(v0)
Drops: v1, v3
End:
  Callsite(v2)

//! > ==========================================================================

//! > Test struct destructure.

//! > test_function_name
test_function_lowering

//! > function
fn foo(s: MyStruct) -> (felt, felt) {
    let MyStruct { a: _, c: (v, _), b} = s;
    (v, b)
}

//! > function_name
foo

//! > module_code
struct MyStruct {
  a: (),
  b: felt,
  c: (felt, felt),
}

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > lowering_format
blk0 (root):
Inputs: v0: test::MyStruct
Statements:
  (v1: (), v2: core::felt, v3: (core::felt, core::felt)) <- struct_destructure(v0)
  (v4: core::felt, v5: core::felt) <- struct_destructure(v3)
  (v6: (core::felt, core::felt)) <- struct_construct(v4, v2)
Drops: v1, v2, v3, v4, v5
End:
  Callsite(v6)
