-
Notifications
You must be signed in to change notification settings - Fork 162
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
Conversation
module->getNamedGlobal(x.m_name)->setInitializer( | ||
llvm::ConstantStruct::get(array_type, | ||
llvm::Constant::getNullValue(array_type))); | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
src/lpython/tests/test_llvm.cpp
Outdated
cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); | ||
PythonCompiler e(cu); | ||
LCompilers::Result<PythonCompiler::EvalResult> | ||
r = e.evaluate2("i: i32[10]"); |
There was a problem hiding this comment.
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)
No description provided.