diff options
author | Li Jin <dragon-fly@qq.com> | 2025-04-11 17:33:12 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2025-04-11 17:33:12 +0800 |
commit | e96308912e2e04535836a2c282b0a7300d2d81fd (patch) | |
tree | 9c6f55dbce6193dac6f78dad94f76ad1c0a6ef1a /src | |
parent | 9750786a5c03b5ce3ea22b240d1b3cd34990856b (diff) | |
download | yuescript-e96308912e2e04535836a2c282b0a7300d2d81fd.tar.gz yuescript-e96308912e2e04535836a2c282b0a7300d2d81fd.tar.bz2 yuescript-e96308912e2e04535836a2c282b0a7300d2d81fd.zip |
Fixing issue #206.v0.27.4
Diffstat (limited to '')
-rw-r--r-- | src/yuescript/yue_ast.h | 1 | ||||
-rw-r--r-- | src/yuescript/yue_compiler.cpp | 12 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/yuescript/yue_ast.h b/src/yuescript/yue_ast.h index e670126..5e70645 100644 --- a/src/yuescript/yue_ast.h +++ b/src/yuescript/yue_ast.h | |||
@@ -620,6 +620,7 @@ AST_END(Slice) | |||
620 | 620 | ||
621 | AST_NODE(Parens) | 621 | AST_NODE(Parens) |
622 | ast_ptr<true, Exp_t> expr; | 622 | ast_ptr<true, Exp_t> expr; |
623 | bool extra = false; | ||
623 | AST_MEMBER(Parens, &expr) | 624 | AST_MEMBER(Parens, &expr) |
624 | AST_END(Parens) | 625 | AST_END(Parens) |
625 | 626 | ||
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp index a2a1864..68ce9b5 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.27.3"sv; | 78 | const std::string_view version = "0.27.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 { |
@@ -1080,8 +1080,8 @@ private: | |||
1080 | if (unary->ops.empty()) { | 1080 | if (unary->ops.empty()) { |
1081 | Value_t* value = static_cast<Value_t*>(unary->expos.back()); | 1081 | Value_t* value = static_cast<Value_t*>(unary->expos.back()); |
1082 | if (auto chain = ast_cast<ChainValue_t>(value->item); chain && chain->items.size() == 1) { | 1082 | if (auto chain = ast_cast<ChainValue_t>(value->item); chain && chain->items.size() == 1) { |
1083 | if (auto exp = chain->get_by_path<Callable_t, Parens_t, Exp_t>()) { | 1083 | if (auto parens = chain->get_by_path<Callable_t, Parens_t>(); parens && parens->extra) { |
1084 | if (auto insideValue = singleValueFrom(exp)) { | 1084 | if (auto insideValue = singleValueFrom(parens->expr)) { |
1085 | return insideValue; | 1085 | return insideValue; |
1086 | } | 1086 | } |
1087 | } | 1087 | } |
@@ -3262,6 +3262,7 @@ private: | |||
3262 | } else if (destruct.items.size() == 1 && !singleValueFrom(*j)) { | 3262 | } else if (destruct.items.size() == 1 && !singleValueFrom(*j)) { |
3263 | auto p = destruct.value.get(); | 3263 | auto p = destruct.value.get(); |
3264 | auto parens = p->new_ptr<Parens_t>(); | 3264 | auto parens = p->new_ptr<Parens_t>(); |
3265 | parens->extra = true; | ||
3265 | if (auto tableBlock = ast_cast<TableBlock_t>(p)) { | 3266 | if (auto tableBlock = ast_cast<TableBlock_t>(p)) { |
3266 | auto tableLit = p->new_ptr<TableLit_t>(); | 3267 | auto tableLit = p->new_ptr<TableLit_t>(); |
3267 | tableLit->values.dup(tableBlock->values); | 3268 | tableLit->values.dup(tableBlock->values); |
@@ -4750,6 +4751,7 @@ private: | |||
4750 | newSimpleValue->value.set(funLit); | 4751 | newSimpleValue->value.set(funLit); |
4751 | auto newExpInParens = newExp(newSimpleValue, x); | 4752 | auto newExpInParens = newExp(newSimpleValue, x); |
4752 | auto newParens = x->new_ptr<Parens_t>(); | 4753 | auto newParens = x->new_ptr<Parens_t>(); |
4754 | newParens->extra = true; | ||
4753 | newParens->expr.set(newExpInParens); | 4755 | newParens->expr.set(newExpInParens); |
4754 | auto newCallable = x->new_ptr<Callable_t>(); | 4756 | auto newCallable = x->new_ptr<Callable_t>(); |
4755 | newCallable->item.set(newParens); | 4757 | newCallable->item.set(newParens); |
@@ -5570,6 +5572,7 @@ private: | |||
5570 | auto x = chainList.front(); | 5572 | auto x = chainList.front(); |
5571 | if (ast_is<ExistentialOp_t>(chainList.back())) { | 5573 | if (ast_is<ExistentialOp_t>(chainList.back())) { |
5572 | auto parens = x->new_ptr<Parens_t>(); | 5574 | auto parens = x->new_ptr<Parens_t>(); |
5575 | parens->extra = true; | ||
5573 | { | 5576 | { |
5574 | auto chainValue = x->new_ptr<ChainValue_t>(); | 5577 | auto chainValue = x->new_ptr<ChainValue_t>(); |
5575 | for (auto item : chainList) { | 5578 | for (auto item : chainList) { |
@@ -6163,6 +6166,7 @@ private: | |||
6163 | ++next; | 6166 | ++next; |
6164 | if (next != chainList.end()) { | 6167 | if (next != chainList.end()) { |
6165 | auto paren = x->new_ptr<Parens_t>(); | 6168 | auto paren = x->new_ptr<Parens_t>(); |
6169 | paren->extra = true; | ||
6166 | paren->expr.set(newExp(chainValue, x)); | 6170 | paren->expr.set(newExp(chainValue, x)); |
6167 | auto ncallable = x->new_ptr<Callable_t>(); | 6171 | auto ncallable = x->new_ptr<Callable_t>(); |
6168 | ncallable->item.set(paren); | 6172 | ncallable->item.set(paren); |
@@ -6215,6 +6219,7 @@ private: | |||
6215 | simpleValue->value.set(funLit); | 6219 | simpleValue->value.set(funLit); |
6216 | auto exp = newExp(simpleValue, x); | 6220 | auto exp = newExp(simpleValue, x); |
6217 | auto paren = x->new_ptr<Parens_t>(); | 6221 | auto paren = x->new_ptr<Parens_t>(); |
6222 | paren->extra = true; | ||
6218 | paren->expr.set(exp); | 6223 | paren->expr.set(exp); |
6219 | auto callable = x->new_ptr<Callable_t>(); | 6224 | auto callable = x->new_ptr<Callable_t>(); |
6220 | callable->item.set(paren); | 6225 | callable->item.set(paren); |
@@ -6631,6 +6636,7 @@ private: | |||
6631 | exp.set(info.node); | 6636 | exp.set(info.node); |
6632 | if (!exp->opValues.empty() || (chainList.size() > 2 || (chainList.size() == 2 && !ast_is<Invoke_t, InvokeArgs_t>(chainList.back())))) { | 6637 | if (!exp->opValues.empty() || (chainList.size() > 2 || (chainList.size() == 2 && !ast_is<Invoke_t, InvokeArgs_t>(chainList.back())))) { |
6633 | auto paren = x->new_ptr<Parens_t>(); | 6638 | auto paren = x->new_ptr<Parens_t>(); |
6639 | paren->extra = true; | ||
6634 | paren->expr.set(exp); | 6640 | paren->expr.set(exp); |
6635 | auto callable = x->new_ptr<Callable_t>(); | 6641 | auto callable = x->new_ptr<Callable_t>(); |
6636 | callable->item.set(paren); | 6642 | callable->item.set(paren); |