Skip to content

Commit 9462148

Browse files
committed
Fix separator in print
1 parent 7eb2bea commit 9462148

File tree

3 files changed

+5
-15
lines changed

3 files changed

+5
-15
lines changed

src/libasr/codegen/asr_to_llvm.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8432,14 +8432,11 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
84328432
args.push_back(nullptr); // reserve space for fmt_str
84338433
std::vector<std::string> fmt;
84348434
llvm::Value *sep = nullptr;
8435-
llvm::Value *sep_no_space = nullptr;
84368435
llvm::Value *end = nullptr;
8437-
bool global_sep_space = false;
84388436
if (x.m_separator) {
84398437
this->visit_expr_wrapper(x.m_separator, true);
84408438
sep = tmp;
84418439
} else {
8442-
global_sep_space = true;
84438440
sep = builder->CreateGlobalStringPtr(" ");
84448441
}
84458442
if (x.m_end) {
@@ -8451,14 +8448,7 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
84518448
for (size_t i=0; i<x.n_values; i++) {
84528449
if (i != 0) {
84538450
fmt.push_back("%s");
8454-
if (global_sep_space &&
8455-
!(ASRUtils::is_character(*ASRUtils::expr_type(x.m_values[i]))
8456-
&& ASRUtils::is_character(*ASRUtils::expr_type(x.m_values[i - 1])))) {
8457-
args.push_back(sep);
8458-
} else {
8459-
sep_no_space = sep_no_space != nullptr ? sep_no_space : builder->CreateGlobalStringPtr("");
8460-
args.push_back(sep_no_space);
8461-
}
8451+
args.push_back(sep);
84628452
}
84638453
compute_fmt_specifier_and_arg(fmt, args, x.m_values[i], x.base.base.loc);
84648454
}

tests/reference/runtime-test_list_item_mixed_print-a3fd49f.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"outfile": null,
77
"outfile_hash": null,
88
"stdout": "runtime-test_list_item_mixed_print-a3fd49f.stdout",
9-
"stdout_hash": "9d9a68fea29f11320efb0764ce38ed3d4090f64457b0f1eb10251a2b",
9+
"stdout_hash": "cffcdb43864ef4e234dec5a10923f9077b7c6d1f4d9c37df1882f375",
1010
"stderr": null,
1111
"stderr_hash": null,
1212
"returncode": 0

tests/reference/runtime-test_list_item_mixed_print-a3fd49f.stdout

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
Hello
2-
This isLPython
1+
Hello
2+
This is LPython
33
1 2 3 ... 3 4 5
44
The first element is: 1
55
The middle element is: 3
66
3.14000000000000012e+00 * 2 = 6.28000000000000025e+00
77
Total: 9.41999999999999993e+00
88
(1, 2, 3) is a tuple, but 1 is a number.
9-
123
9+
1 is smaller than 2 is smaller than 3
1010
1 # 2 # 3 # 4 # 5 #
1111

1212
List 0 : [1, 2]

0 commit comments

Comments
 (0)