From 7de25e2ef75a748356c79d0015a5d934dde4c216 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Tue, 19 Dec 2023 23:29:07 +0800 Subject: fix a const list destructuring case. --- src/yuescript/yue_ast.h | 3 ++- src/yuescript/yue_compiler.cpp | 5 +++-- src/yuescript/yue_parser.cpp | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/yuescript/yue_ast.h b/src/yuescript/yue_ast.h index 6b2b7f8..6d90add 100644 --- a/src/yuescript/yue_ast.h +++ b/src/yuescript/yue_ast.h @@ -80,6 +80,7 @@ class Macro_t; class In_t; class NormalDef_t; class SpreadListExp_t; +class Comprehension_t; } // namespace yue AST_LEAF(Num) @@ -171,7 +172,7 @@ AST_END(CloseAttrib, "close"sv) AST_NODE(LocalAttrib) ast_sel attrib; ast_ptr sep; - ast_sel_list leftList; + ast_sel_list leftList; ast_ptr assign; AST_MEMBER(LocalAttrib, &attrib, &sep, &leftList, &assign) AST_END(LocalAttrib, "local_attrib"sv) diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp index d43f79b..f163bdf 100644 --- a/src/yuescript/yue_compiler.cpp +++ b/src/yuescript/yue_compiler.cpp @@ -75,7 +75,7 @@ static std::unordered_set Metamethods = { "close"s // Lua 5.4 }; -const std::string_view version = "0.21.5"sv; +const std::string_view version = "0.21.6"sv; const std::string_view extension = "yue"sv; class CompileError : public std::logic_error { @@ -9376,7 +9376,8 @@ private: case id(): value->item.set(item); break; - case id(): { + case id(): + case id(): { auto simpleValue = item->new_ptr(); simpleValue->value.set(item); value->item.set(simpleValue); diff --git a/src/yuescript/yue_parser.cpp b/src/yuescript/yue_parser.cpp index 3557534..4e6105b 100644 --- a/src/yuescript/yue_parser.cpp +++ b/src/yuescript/yue_parser.cpp @@ -286,7 +286,7 @@ YueParser::YueParser() { ConstAttrib = key("const"); CloseAttrib = key("close"); - local_const_item = Variable | SimpleTable | TableLit; + local_const_item = Variable | SimpleTable | TableLit | Comprehension; LocalAttrib = ( ConstAttrib >> Seperator >> space >> local_const_item >> *(space >> ',' >> space >> local_const_item) | CloseAttrib >> Seperator >> space >> Variable >> *(space >> ',' >> space >> Variable) -- cgit v1.2.3-55-g6feb