Closed Vipul-Cariappa closed 1 month ago
@Shaikh-Ubaid, Please have a look at the comments I have left. Do let me know, if I am not clear.
After having a look at the comments, read the following part:
We can otherwise implement it as an ASR pass. Identify the last expression and wrap the print
function around it. This ASR pass will only be enabled when using the interactive mode.
We can otherwise implement it as an ASR pass. Identify the last expression and wrap the print function around it. This ASR pass will only be enabled when using the interactive mode.
I clarified this in my review comment above.
Also, you need to update the reference tests for the CI to pass.
Replying to https://github.com/lcompilers/lpython/pull/2698#pullrequestreview-2051417737
Let's say we made the necessary modifications such that we return a value from the function generated from pass_wrap_global_stmt
. But what if the return type is list
or dict
. We would not be able to print it. Code to print list
or dict
should be produced at the LLVM backend level.
Reference:
The function generated by pass_wrap_global_stmt
is being called by PythonCompiler::evaluate
(look at https://github.com/lcompilers/lpython/blob/6aed371ba12a2b55e7284483dad651aa3982600e/src/lpython/python_evaluator.cpp#L114-L149). And then being printed by interactive_python_repl
(Look at https://github.com/lcompilers/lpython/blob/6aed371ba12a2b55e7284483dad651aa3982600e/src/bin/lpython.cpp#L890-L944).
@Vipul-Cariappa Is this safe to close? If it is, can you close this?
Closed by #2716
Example:
Present behavior:
Expected behavior (after potentially merging this PR):
Reference for myself Things to do: