diff options
Diffstat (limited to '')
| -rw-r--r-- | src/yuescript/yue_compiler.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp index 648dab2..1733967 100644 --- a/src/yuescript/yue_compiler.cpp +++ b/src/yuescript/yue_compiler.cpp | |||
| @@ -75,7 +75,7 @@ static std::unordered_set<std::string> Metamethods = { | |||
| 75 | "close"s // Lua 5.4 | 75 | "close"s // Lua 5.4 |
| 76 | }; | 76 | }; |
| 77 | 77 | ||
| 78 | const std::string_view version = "0.20.3"sv; | 78 | const std::string_view version = "0.20.4"sv; |
| 79 | const std::string_view extension = "yue"sv; | 79 | const std::string_view extension = "yue"sv; |
| 80 | 80 | ||
| 81 | class CompileError : public std::logic_error { | 81 | class CompileError : public std::logic_error { |
| @@ -9155,8 +9155,15 @@ private: | |||
| 9155 | for (auto branch_ : branches) { | 9155 | for (auto branch_ : branches) { |
| 9156 | auto branch = static_cast<SwitchCase_t*>(branch_); | 9156 | auto branch = static_cast<SwitchCase_t*>(branch_); |
| 9157 | auto valueList = static_cast<SwitchList_t*>(branch->condition.get()); | 9157 | auto valueList = static_cast<SwitchList_t*>(branch->condition.get()); |
| 9158 | if (auto value = singleValueFrom(valueList); | 9158 | bool tableMatching = false; |
| 9159 | value && (value->item.is<SimpleTable_t>() || value->get_by_path<SimpleValue_t, TableLit_t>())) { | 9159 | if (auto value = singleValueFrom(valueList)) { |
| 9160 | if (value->item.is<SimpleTable_t>()) { | ||
| 9161 | tableMatching = true; | ||
| 9162 | } else if (auto sVal = value->item.as<SimpleValue_t>()){ | ||
| 9163 | tableMatching = ast_is<TableLit_t, Comprehension_t>(sVal->value); | ||
| 9164 | } | ||
| 9165 | } | ||
| 9166 | if (tableMatching) { | ||
| 9160 | if (!firstBranch) { | 9167 | if (!firstBranch) { |
| 9161 | temp.push_back(indent() + "else"s + nll(branch)); | 9168 | temp.push_back(indent() + "else"s + nll(branch)); |
| 9162 | pushScope(); | 9169 | pushScope(); |
