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

fix array symbol duplication in interactive mode #2734

Merged
merged 3 commits into from
Jul 3, 2024

Conversation

Vipul-Cariappa
Copy link
Contributor

No description provided.

@Vipul-Cariappa
Copy link
Contributor Author

cc @Shaikh-Ubaid

module->getNamedGlobal(x.m_name)->setInitializer(
llvm::ConstantStruct::get(array_type,
llvm::Constant::getNullValue(array_type)));
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Vipul-Cariappa can you add a test that was failing previously in interactive mode and now works?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On main you will get the following error:

>>> i: i32[10]                                                                                                                         1,11  ]
>>> print(i)                                                                                                                           1,9   ]
Internal Compiler Error: Unhandled exception
Traceback (most recent call last):
  Binary file "/home/vipul/Workspace/python/lpython/src/bin/lpython", in _start()
  Binary file "/lib64/libc.so.6", in __libc_start_main_alias_2()
  Binary file "/lib64/libc.so.6", in __libc_start_call_main()
  File "/home/vipul/Workspace/python/lpython/src/bin/lpython.cpp", line 2061, in main()
    return interactive_python_repl(lpython_pass_manager, compiler_options, arg_v);
  File "/home/vipul/Workspace/python/lpython/src/bin/lpython.cpp", line 883, in interactive_python_repl()
    res = fe.evaluate(code_string, verbose, lm, pass_manager, diagnostics);
  File "/home/vipul/Workspace/python/lpython/src/lpython/python_evaluator.cpp", line 128, in LCompilers::PythonCompiler::evaluate(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, LCompilers::LocationManager&, LCompilers::PassManager&, LCompilers::diag::Diagnostics&)
    e->add_module(std::move(m));
  File "/home/vipul/Workspace/python/lpython/src/libasr/codegen/evaluator.cpp", line 252, in LCompilers::LLVMEvaluator::add_module(std::unique_ptr<LCompilers::LLVMModule, std::default_delete<LCompilers::LLVMModule> >)
    add_module(std::move(m->m_m));
LCompilersException: addModule() returned an error: Duplicate definition of symbol 'i'

I have added in the test.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue shared and fix in this PR might be real, but the test example shared in the above comment does not look right.

(lp) ubaid@ubaids-MacBook-Pro lpython % python examples/expr2.py 
Traceback (most recent call last):
  File "/Users/ubaid/Desktop/OpenSource/lpython/examples/expr2.py", line 4, in <module>
    print(i)
NameError: name 'i' is not defined. Did you mean: 'id'?

It does not work with CPython. We should only support tests or cases that work with CPython first, then work with LPython regular/normal mode and finally support them in LPython interactive mode.

cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir();
PythonCompiler e(cu);
LCompilers::Result<PythonCompiler::EvalResult>
r = e.evaluate2("i: i32[10]");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, I think we should have it like

>>> i: i32[10] = empty(10, dtype=int32)                                                          1,36  ]
>>> print(i)  

@Shaikh-Ubaid Shaikh-Ubaid enabled auto-merge (squash) July 3, 2024 13:59
@Shaikh-Ubaid Shaikh-Ubaid merged commit 065a58a into lcompilers:main Jul 3, 2024
14 checks passed
@Vipul-Cariappa Vipul-Cariappa deleted the asr-sync branch July 27, 2024 12:23
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 this pull request may close these issues.

2 participants