lcompilers / lpython

Python compiler
https://lpython.org/
Other
1.37k stars 156 forks source link

Fixes complex datatype's symbol duplication bug while using interactive #2707

Closed Vipul-Cariappa closed 1 month ago

Vipul-Cariappa commented 1 month ago

Orginal Bug:

❯ lp
>>> l: list[i32] = [1, 2, 3]
>>> print(l)
Internal Compiler Error: Unhandled exception
Traceback (most recent call last):
  Binary file "/home/vipul/Workspace/bin/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()
  Binary file "/home/vipul/Workspace/bin/lpython/src/bin/lpython", in main()
  File "lpython.cpp", line 0, in (anonymous namespace)::interactive_python_repl(LCompilers::PassManager&, LCompilers::CompilerOptions&, bool) [clone .isra.0]
  Binary file "/home/vipul/Workspace/bin/lpython/src/bin/lpython", 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&)
LCompilersException: addModule() returned an error: Duplicate definition of symbol 'l'

I just followed the way visit_Variable handles normal integer types and adapted it to work with list, dict, etc.

Vipul-Cariappa commented 1 month ago

cc: @Shaikh-Ubaid