Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(PRIMA) Handle ArrayReference with ArrayConstant indices in ArrayConstructor #5779

Closed
jinangshah21 opened this issue Dec 21, 2024 · 1 comment · Fixed by #5798
Closed

(PRIMA) Handle ArrayReference with ArrayConstant indices in ArrayConstructor #5779

jinangshah21 opened this issue Dec 21, 2024 · 1 comment · Fixed by #5798

Comments

@jinangshah21
Copy link
Contributor

MRE :

program test
integer :: x(4) = [1,2,3,2]
integer :: y(3) = [0,0,0]
integer :: z = 2
y = [z, x([1,2])] 
print *,y
end program

LFortran Error :

Traceback (most recent call last):
  Binary file "/mnt/c/lfortran/src/bin/lfortran", in _start
  File "/build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c", line 308, in __libc_start_main
  File "/mnt/c/lfortran/src/bin/lfortran.cpp", line 2728, in main
    return main_app(argc, argv);
  File "/mnt/c/lfortran/src/bin/lfortran.cpp", line 2666, in main_app(int, char**)
    err = compile_src_to_object_file(arg_file, tmp_o, false,
  File "/mnt/c/lfortran/src/bin/lfortran.cpp", line 1049, in (anonymous namespace)::compile_src_to_object_file(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, LCompilers::CompilerOptions&, LCompilers::PassManager&)
    res = fe.get_llvm3(*asr, lpm, diagnostics, infile);
  File "/mnt/c/lfortran/src/lfortran/fortran_evaluator.cpp", line 382, in LCompilers::FortranEvaluator::get_llvm3(LCompilers::ASR::TranslationUnit_t&, LCompilers::PassManager&, LCompilers::diag::Diagnostics&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
    compiler_options, run_fn, infile);
  File "/mnt/c/lfortran/src/libasr/codegen/asr_to_llvm.cpp", line 10462, in LCompilers::asr_to_llvm(LCompilers::ASR::TranslationUnit_t&, LCompilers::diag::Diagnostics&, llvm::LLVMContext&, Allocator&, LCompilers::PassManager&, LCompilers::CompilerOptions&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
    v.visit_asr((ASR::asr_t&)asr);
  File "/mnt/c/lfortran/src/libasr/../libasr/asr_base_visitor.h", line 316, in LCompilers::ASR::BaseVisitor<LCompilers::ASRToLLVMVisitor>::visit_asr(LCompilers::ASR::asr_t const&)
    void visit_asr(const asr_t &b) { visit_asr_t(b, self()); }
  File "/mnt/c/lfortran/src/libasr/../libasr/asr_base_visitor.h", line 292, in void LCompilers::ASR::visit_asr_t<LCompilers::ASRToLLVMVisitor>(LCompilers::ASR::asr_t const&, LCompilers::ASRToLLVMVisitor&)
    case asrType::unit: { v.visit_unit((const unit_t &)x); return; }
  File "/mnt/c/lfortran/src/libasr/../libasr/asr_base_visitor.h", line 317, in LCompilers::ASR::BaseVisitor<LCompilers::ASRToLLVMVisitor>::visit_unit(LCompilers::ASR::unit_t const&)
    void visit_unit(const unit_t &b) { visit_unit_t(b, self()); }
  File "/mnt/c/lfortran/src/libasr/../libasr/asr_base_visitor.h", line 22, in void LCompilers::ASR::visit_unit_t<LCompilers::ASRToLLVMVisitor>(LCompilers::ASR::unit_t const&, LCompilers::ASRToLLVMVisitor&)
    case unitType::TranslationUnit: { v.visit_TranslationUnit((const TranslationUnit_t &)x); return; }
  File "/mnt/c/lfortran/src/libasr/codegen/asr_to_llvm.cpp", line 988, in LCompilers::ASRToLLVMVisitor::visit_TranslationUnit(LCompilers::ASR::TranslationUnit_t const&)
    visit_symbol(*item.second);
  File "/mnt/c/lfortran/src/libasr/../libasr/asr_base_visitor.h", line 319, in LCompilers::ASR::BaseVisitor<LCompilers::ASRToLLVMVisitor>::visit_symbol(LCompilers::ASR::symbol_t const&)
    void visit_symbol(const symbol_t &b) { visit_symbol_t(b, self()); }
  File "/mnt/c/lfortran/src/libasr/../libasr/asr_base_visitor.h", line 30, in void LCompilers::ASR::visit_symbol_t<LCompilers::ASRToLLVMVisitor>(LCompilers::ASR::symbol_t const&, LCompilers::ASRToLLVMVisitor&)
    case symbolType::Program: { v.visit_Program((const Program_t &)x); return; }
  File "/mnt/c/lfortran/src/libasr/codegen/asr_to_llvm.cpp", line 3311, in LCompilers::ASRToLLVMVisitor::visit_Program(LCompilers::ASR::Program_t const&)
    this->visit_stmt(*x.m_body[i]);
  File "/mnt/c/lfortran/src/libasr/../libasr/asr_base_visitor.h", line 336, in LCompilers::ASR::BaseVisitor<LCompilers::ASRToLLVMVisitor>::visit_stmt(LCompilers::ASR::stmt_t const&)
    void visit_stmt(const stmt_t &b) { visit_stmt_t(b, self()); }
  File "/mnt/c/lfortran/src/libasr/../libasr/asr_base_visitor.h", line 85, in void LCompilers::ASR::visit_stmt_t<LCompilers::ASRToLLVMVisitor>(LCompilers::ASR::stmt_t const&, LCompilers::ASRToLLVMVisitor&)
    case stmtType::WhileLoop: { v.visit_WhileLoop((const WhileLoop_t &)x); return; }
  File "/mnt/c/lfortran/src/libasr/codegen/asr_to_llvm.cpp", line 6112, in LCompilers::ASRToLLVMVisitor::visit_WhileLoop(LCompilers::ASR::WhileLoop_t const&)
    create_loop(x.m_name, [=]() {
  File "/mnt/c/lfortran/src/libasr/codegen/asr_to_llvm.cpp", line 321, in void LCompilers::ASRToLLVMVisitor::create_loop<LCompilers::ASRToLLVMVisitor::visit_WhileLoop(LCompilers::ASR::WhileLoop_t const&)::'lambda'(), LCompilers::ASRToLLVMVisitor::visit_WhileLoop(LCompilers::ASR::WhileLoop_t const&)::'lambda0'()>(char*, LCompilers::ASRToLLVMVisitor::visit_WhileLoop(LCompilers::ASR::WhileLoop_t const&)::'lambda'(), LCompilers::ASRToLLVMVisitor::visit_WhileLoop(LCompilers::ASR::WhileLoop_t const&)::'lambda0'())
    loop_body();
  File "/mnt/c/lfortran/src/libasr/codegen/asr_to_llvm.cpp", line 6118, in LCompilers::ASRToLLVMVisitor::visit_WhileLoop(LCompilers::ASR::WhileLoop_t const&)::'lambda0'()::operator()() const
    this->visit_stmt(*x.m_body[i]);
  File "/mnt/c/lfortran/src/libasr/../libasr/asr_base_visitor.h", line 336, in LCompilers::ASR::BaseVisitor<LCompilers::ASRToLLVMVisitor>::visit_stmt(LCompilers::ASR::stmt_t const&)
    void visit_stmt(const stmt_t &b) { visit_stmt_t(b, self()); }
  File "/mnt/c/lfortran/src/libasr/../libasr/asr_base_visitor.h", line 56, in void LCompilers::ASR::visit_stmt_t<LCompilers::ASRToLLVMVisitor>(LCompilers::ASR::stmt_t const&, LCompilers::ASRToLLVMVisitor&)
    case stmtType::Assignment: { v.visit_Assignment((const Assignment_t &)x); return; }
  File "/mnt/c/lfortran/src/libasr/codegen/asr_to_llvm.cpp", line 5173, in LCompilers::ASRToLLVMVisitor::visit_Assignment(LCompilers::ASR::Assignment_t const&)
    this->visit_expr_wrapper(m_value, true);
  File "/mnt/c/lfortran/src/libasr/codegen/asr_to_llvm.cpp", line 5578, in LCompilers::ASRToLLVMVisitor::visit_expr_wrapper(LCompilers::ASR::expr_t*, bool)
    this->visit_expr(*x);
  File "/mnt/c/lfortran/src/libasr/../libasr/asr_base_visitor.h", line 384, in LCompilers::ASR::BaseVisitor<LCompilers::ASRToLLVMVisitor>::visit_expr(LCompilers::ASR::expr_t const&)
    void visit_expr(const expr_t &b) { visit_expr_t(b, self()); }
  File "/mnt/c/lfortran/src/libasr/../libasr/asr_base_visitor.h", line 173, in void LCompilers::ASR::visit_expr_t<LCompilers::ASRToLLVMVisitor>(LCompilers::ASR::expr_t const&, LCompilers::ASRToLLVMVisitor&)
    case exprType::ArrayItem: { v.visit_ArrayItem((const ArrayItem_t &)x); return; }
  File "/mnt/c/lfortran/src/libasr/codegen/asr_to_llvm.cpp", line 2373, in LCompilers::ASRToLLVMVisitor::visit_ArrayItem(LCompilers::ASR::ArrayItem_t const&)
    this->visit_expr_wrapper(curr_idx.m_right, true);
  File "/mnt/c/lfortran/src/libasr/codegen/asr_to_llvm.cpp", line 5578, in LCompilers::ASRToLLVMVisitor::visit_expr_wrapper(LCompilers::ASR::expr_t*, bool)
    this->visit_expr(*x);
  File "/mnt/c/lfortran/src/libasr/../libasr/asr_base_visitor.h", line 384, in LCompilers::ASR::BaseVisitor<LCompilers::ASRToLLVMVisitor>::visit_expr(LCompilers::ASR::expr_t const&)
    void visit_expr(const expr_t &b) { visit_expr_t(b, self()); }
  File "/mnt/c/lfortran/src/libasr/../libasr/asr_base_visitor.h", line 173, in void LCompilers::ASR::visit_expr_t<LCompilers::ASRToLLVMVisitor>(LCompilers::ASR::expr_t const&, LCompilers::ASRToLLVMVisitor&)
    case exprType::ArrayItem: { v.visit_ArrayItem((const ArrayItem_t &)x); return; }
  File "/mnt/c/lfortran/src/libasr/codegen/asr_to_llvm.cpp", line 2382, in LCompilers::ASRToLLVMVisitor::visit_ArrayItem(LCompilers::ASR::ArrayItem_t const&)
    bool is_bindc_array = ASRUtils::expr_abi(x.m_v) == ASR::abiType::BindC;
LCompilersException: Cannot extract the ABI of ASR::exprType::65 expression.
@jinangshah21
Copy link
Contributor Author

I will do it as I have done similar kind of issue previously.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant