lcompilers / lpython

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

Add space between multiple strings while printing #2670

Open kmr-srbh opened 2 months ago

kmr-srbh commented 2 months ago

fixes #2669

print("a", "b", "c", "d")

fruits: list[str] = ["apple", "guava", "mango"]
mango: str = fruits.pop()
print("I have got a", mango, "to eat!")
(base) saurabh-kumar@Awadh:~/Projects/System/lpython$ ./src/bin/lpython ./examples/example.py
a b c d
I have got a mango to eat!
kmr-srbh commented 2 months ago

@Shaikh-Ubaid could you please rerun the CI? The failing check is unrelated to the PR.

Shaikh-Ubaid commented 2 months ago

The approach in this PR might break lfortran. lfortran needs to not print spaces when two consecutive print arguments are strings.

% cat examples/expr2.f90     
program expr2
implicit none

print *, "hi", "bye"
print *, 12, 23

end program
% gfortran examples/expr2.f90 
% ./a.out 
 hibye
          12          23
% lfortran examples/expr2.f90
hibye
12 23