aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/yuescript/yue_compiler.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp
index 6bc9fe8..6c8e167 100755
--- a/src/yuescript/yue_compiler.cpp
+++ b/src/yuescript/yue_compiler.cpp
@@ -60,7 +60,7 @@ using namespace parserlib;
60 60
61typedef std::list<std::string> str_list; 61typedef std::list<std::string> str_list;
62 62
63const std::string_view version = "0.9.10"sv; 63const std::string_view version = "0.9.11"sv;
64const std::string_view extension = "yue"sv; 64const std::string_view extension = "yue"sv;
65 65
66class YueCompilerImpl { 66class YueCompilerImpl {
@@ -3539,7 +3539,19 @@ private:
3539 } 3539 }
3540 BLOCK_END 3540 BLOCK_END
3541 auto objVar = singleVariableFrom(partOne); 3541 auto objVar = singleVariableFrom(partOne);
3542 if (objVar.empty()) { 3542 bool isScoped = false;
3543 if (objVar.empty() || !isLocal(objVar)) {
3544 switch (usage) {
3545 case ExpUsage::Common:
3546 case ExpUsage::Assignment:
3547 isScoped = true;
3548 break;
3549 default: break;
3550 }
3551 if (isScoped) {
3552 temp.push_back(indent() + "do"s + nll(x));
3553 pushScope();
3554 }
3543 objVar = getUnusedName("_obj_"sv); 3555 objVar = getUnusedName("_obj_"sv);
3544 if (auto colonItem = ast_cast<ColonChainItem_t>(partOne->items.back())) { 3556 if (auto colonItem = ast_cast<ColonChainItem_t>(partOne->items.back())) {
3545 auto chainValue = x->new_ptr<ChainValue_t>(); 3557 auto chainValue = x->new_ptr<ChainValue_t>();
@@ -3549,7 +3561,7 @@ private:
3549 if (_withVars.empty()) { 3561 if (_withVars.empty()) {
3550 throw std::logic_error(_info.errorMessage("short dot/colon syntax must be called within a with block"sv, x)); 3562 throw std::logic_error(_info.errorMessage("short dot/colon syntax must be called within a with block"sv, x));
3551 } 3563 }
3552 chainValue->items.push_back(toAst<Callable_t>(_withVars.top(), x)); 3564 chainValue->items.push_back(toAst<Callable_t>(_withVars.top(), x));
3553 } 3565 }
3554 auto newObj = singleVariableFrom(chainValue); 3566 auto newObj = singleVariableFrom(chainValue);
3555 if (!newObj.empty()) { 3567 if (!newObj.empty()) {
@@ -3650,6 +3662,10 @@ private:
3650 default: 3662 default:
3651 break; 3663 break;
3652 } 3664 }
3665 if (isScoped) {
3666 popScope();
3667 temp.push_back(indent() + "end"s + nlr(x));
3668 }
3653 out.push_back(join(temp)); 3669 out.push_back(join(temp));
3654 return true; 3670 return true;
3655 } 3671 }