From 82e9b379db4eb77f82cf5693e476597feb18e40b Mon Sep 17 00:00:00 2001 From: Li Jin Date: Thu, 12 Feb 2026 09:35:43 +0800 Subject: Fixed a format issue. --- src/yuescript/yue_ast.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/yuescript/yue_ast.cpp b/src/yuescript/yue_ast.cpp index 9c398c8..3953f97 100644 --- a/src/yuescript/yue_ast.cpp +++ b/src/yuescript/yue_ast.cpp @@ -790,6 +790,7 @@ static bool isInBlockExp(ast_node* node, bool last = false) { return false; } std::string Comprehension_t::to_string(void* ud) const { + auto info = reinterpret_cast(ud); if (items.size() != 2 || !ast_is(items.back())) { if (items.size() == 1) { str_list temp; @@ -799,6 +800,9 @@ std::string Comprehension_t::to_string(void* ud) const { if (temp.size() > 0) { temp.front().insert(0, temp.front()[0] == '[' ? " "s : ""s); } + if (std::string_view{temp.front().c_str(), 3} == "for"sv) { + return "[\n"s + info->ind() + join(temp, ", "sv) + '\n' + info->ind() + ']'; + } return '[' + join(temp, ", "sv) + ",]"s; } else { bool hasInBlockExp = false; @@ -809,7 +813,6 @@ std::string Comprehension_t::to_string(void* ud) const { } } if (hasInBlockExp) { - auto info = reinterpret_cast(ud); str_list temp; temp.emplace_back("["s); info->pushScope(); -- cgit v1.2.3-55-g6feb