aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2021-02-18 11:54:14 +0800
committerLi Jin <dragon-fly@qq.com>2021-02-18 11:54:14 +0800
commit3ea3f9b1c42eae103c370a986f539a0f1550db9f (patch)
treea3e742d8dbae652c240db20b3a40d3532f387d20 /src
parentcca77d89903fc3a28f8500d5621dc9ca7697ae1d (diff)
downloadyuescript-3ea3f9b1c42eae103c370a986f539a0f1550db9f.tar.gz
yuescript-3ea3f9b1c42eae103c370a986f539a0f1550db9f.tar.bz2
yuescript-3ea3f9b1c42eae103c370a986f539a0f1550db9f.zip
prevent inserting global or local statements with wildcard operators from macro. update changelog.
Diffstat (limited to 'src')
-rw-r--r--src/yuescript/yue_compiler.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp
index 4917e4e..7be0c84 100644
--- a/src/yuescript/yue_compiler.cpp
+++ b/src/yuescript/yue_compiler.cpp
@@ -58,7 +58,7 @@ inline std::string s(std::string_view sv) {
58 return std::string(sv); 58 return std::string(sv);
59} 59}
60 60
61const std::string_view version = "0.6.6"sv; 61const std::string_view version = "0.6.7"sv;
62const std::string_view extension = "yue"sv; 62const std::string_view extension = "yue"sv;
63 63
64class YueCompilerImpl { 64class YueCompilerImpl {
@@ -3460,6 +3460,20 @@ private:
3460 info.node.set(exp); 3460 info.node.set(exp);
3461 } 3461 }
3462 } 3462 }
3463 if (auto block = info.node.as<Block_t>()) {
3464 for (auto stmt_ : block->statements.objects()) {
3465 auto stmt = static_cast<Statement_t*>(stmt_);
3466 if (auto global = stmt->content.as<Global_t>()) {
3467 if (global->item.is<global_op_t>()) {
3468 throw std::logic_error(_info.errorMessage(s("can not insert global statement with wildcard operator from macro"sv), x));
3469 }
3470 } else if (auto local = stmt->content.as<Local_t>()) {
3471 if (local->item.is<local_flag_t>()) {
3472 throw std::logic_error(_info.errorMessage(s("can not insert local statement with wildcard operator from macro"sv), x));
3473 }
3474 }
3475 }
3476 }
3463 return {info.node, std::move(info.codes), Empty, std::move(localVars)}; 3477 return {info.node, std::move(info.codes), Empty, std::move(localVars)};
3464 } else { 3478 } else {
3465 if (!isBlock) throw std::logic_error(_info.errorMessage(s("failed to expanded empty macro as expr"sv), x)); 3479 if (!isBlock) throw std::logic_error(_info.errorMessage(s("failed to expanded empty macro as expr"sv), x));