Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,7 @@ RUN(NAME structs_27 LABELS cpython llvm c)
RUN(NAME structs_28 LABELS cpython llvm c)
RUN(NAME structs_29 LABELS cpython llvm)
RUN(NAME structs_30 LABELS cpython llvm c)
RUN(NAME structs_31 LABELS cpython llvm c)

RUN(NAME symbolics_01 LABELS cpython_sym c_sym)
RUN(NAME symbolics_02 LABELS cpython_sym c_sym)
Expand Down
22 changes: 22 additions & 0 deletions integration_tests/structs_31.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from lpython import packed, dataclass, i32, InOut

@packed
@dataclass
class inner_struct:
a: i32

@packed
@dataclass
class outer_struct:
b: inner_struct = inner_struct(0)

def update_my_inner_struct(my_inner_struct: InOut[inner_struct]) -> None:
my_inner_struct.a = 99999

def main() -> None:
my_outer_struct: outer_struct = outer_struct()

update_my_inner_struct(my_outer_struct.b)
assert my_outer_struct.b.a == 99999

main()
2 changes: 1 addition & 1 deletion src/libasr/codegen/asr_to_c_cpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -2618,7 +2618,7 @@ PyMODINIT_FUNC PyInit_lpython_module_)" + fn_name + R"((void) {
}
} else {
self().visit_expr(*x.m_args[i].m_value);
if( ASR::is_a<ASR::ArrayItem_t>(*x.m_args[i].m_value) &&
if( ASR::is_a<ASR::ArrayItem_t>(*x.m_args[i].m_value) ||
ASR::is_a<ASR::Struct_t>(*ASRUtils::expr_type(x.m_args[i].m_value)) ) {
out += "&" + src;
} else {
Expand Down