aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/yuescript/yue_ast.cpp5
1 files changed, 4 insertions, 1 deletions
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) {
790 return false; 790 return false;
791} 791}
792std::string Comprehension_t::to_string(void* ud) const { 792std::string Comprehension_t::to_string(void* ud) const {
793 auto info = reinterpret_cast<YueFormat*>(ud);
793 if (items.size() != 2 || !ast_is<CompFor_t>(items.back())) { 794 if (items.size() != 2 || !ast_is<CompFor_t>(items.back())) {
794 if (items.size() == 1) { 795 if (items.size() == 1) {
795 str_list temp; 796 str_list temp;
@@ -799,6 +800,9 @@ std::string Comprehension_t::to_string(void* ud) const {
799 if (temp.size() > 0) { 800 if (temp.size() > 0) {
800 temp.front().insert(0, temp.front()[0] == '[' ? " "s : ""s); 801 temp.front().insert(0, temp.front()[0] == '[' ? " "s : ""s);
801 } 802 }
803 if (std::string_view{temp.front().c_str(), 3} == "for"sv) {
804 return "[\n"s + info->ind() + join(temp, ", "sv) + '\n' + info->ind() + ']';
805 }
802 return '[' + join(temp, ", "sv) + ",]"s; 806 return '[' + join(temp, ", "sv) + ",]"s;
803 } else { 807 } else {
804 bool hasInBlockExp = false; 808 bool hasInBlockExp = false;
@@ -809,7 +813,6 @@ std::string Comprehension_t::to_string(void* ud) const {
809 } 813 }
810 } 814 }
811 if (hasInBlockExp) { 815 if (hasInBlockExp) {
812 auto info = reinterpret_cast<YueFormat*>(ud);
813 str_list temp; 816 str_list temp;
814 temp.emplace_back("["s); 817 temp.emplace_back("["s);
815 info->pushScope(); 818 info->pushScope();