diff --git a/integration_tests/CMakeLists.txt b/integration_tests/CMakeLists.txt index 3540040ea6..8765026195 100644 --- a/integration_tests/CMakeLists.txt +++ b/integration_tests/CMakeLists.txt @@ -703,6 +703,8 @@ RUN(NAME structs_32 LABELS cpython llvm c) RUN(NAME structs_33 LABELS cpython llvm c) RUN(NAME structs_34 LABELS cpython llvm c) RUN(NAME structs_35 LABELS cpython llvm) +RUN(NAME structs_36 LABELS cpython llvm) +RUN(NAME structs_37 LABELS cpython llvm) RUN(NAME symbolics_01 LABELS cpython_sym c_sym llvm_sym NOFAST) RUN(NAME symbolics_02 LABELS cpython_sym c_sym llvm_sym NOFAST) diff --git a/integration_tests/structs_36.py b/integration_tests/structs_36.py new file mode 100644 index 0000000000..1f6ee9a26f --- /dev/null +++ b/integration_tests/structs_36.py @@ -0,0 +1,10 @@ +from lpython import dataclass + +@dataclass +class Transaction: + date: str + name: str + +@dataclass +class Transactions: + transactions: list[Transaction] \ No newline at end of file diff --git a/integration_tests/structs_37.py b/integration_tests/structs_37.py new file mode 100644 index 0000000000..83d1953d06 --- /dev/null +++ b/integration_tests/structs_37.py @@ -0,0 +1,4 @@ +from structs_36 import Transactions, Transaction + +transactions: list[Transaction] = [] +asr: Transactions = Transactions(transactions=transactions) \ No newline at end of file diff --git a/src/libasr/asr_verify.cpp b/src/libasr/asr_verify.cpp index 7f6dc8484b..007d6571ed 100644 --- a/src/libasr/asr_verify.cpp +++ b/src/libasr/asr_verify.cpp @@ -1090,6 +1090,15 @@ class VerifyVisitor : public BaseWalkVisitor if( ASRUtils::get_asr_owner(x.m_derived_type) ) { symbol_owner = ASRUtils::symbol_name(ASRUtils::get_asr_owner(x.m_derived_type)); } + + // Resolve the symbol in the current symbol table. + ASR::symbol_t* symbol = current_symtab->resolve_symbol(ASRUtils::symbol_name(x.m_derived_type)); + + // If the symbol is an ExternalSymbol, then omit the check. + if (ASR::is_a(*symbol)) { + return; + } + require(symtab_in_scope(current_symtab, x.m_derived_type), "Struct::m_derived_type '" + std::string(ASRUtils::symbol_name(x.m_derived_type)) +