diff options
author | Li Jin <dragon-fly@qq.com> | 2022-09-08 18:04:50 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2022-09-08 18:04:50 +0800 |
commit | 27b7211e74d5677fbf5c5212264d32c7bfaffc20 (patch) | |
tree | 7031464c3a2a5d977ffa7ae26481a7280d8f8ece | |
parent | 269b1fbf5d4d2c9ad33e75fb000d388b8391cb0f (diff) | |
download | yuescript-27b7211e74d5677fbf5c5212264d32c7bfaffc20.tar.gz yuescript-27b7211e74d5677fbf5c5212264d32c7bfaffc20.tar.bz2 yuescript-27b7211e74d5677fbf5c5212264d32c7bfaffc20.zip |
added a missing scope.
-rw-r--r-- | spec/inputs/destructure.yue | 6 | ||||
-rw-r--r-- | spec/outputs/destructure.lua | 19 | ||||
-rwxr-xr-x | src/yuescript/yue_compiler.cpp | 7 |
3 files changed, 29 insertions, 3 deletions
diff --git a/spec/inputs/destructure.yue b/spec/inputs/destructure.yue index ce593ec..403923a 100644 --- a/spec/inputs/destructure.yue +++ b/spec/inputs/destructure.yue | |||
@@ -210,3 +210,9 @@ do | |||
210 | when {:<name> = "item", <"123">: meta_field} | 210 | when {:<name> = "item", <"123">: meta_field} |
211 | print name, meta_field | 211 | print name, meta_field |
212 | 212 | ||
213 | do | ||
214 | tb = {} | ||
215 | <[a + b]>: v1, [c!]: v2 = tb | ||
216 | |||
217 | nil | ||
218 | |||
diff --git a/spec/outputs/destructure.lua b/spec/outputs/destructure.lua index 0da920e..10ad2d0 100644 --- a/spec/outputs/destructure.lua +++ b/spec/outputs/destructure.lua | |||
@@ -470,8 +470,8 @@ do | |||
470 | end) | 470 | end) |
471 | end | 471 | end |
472 | end | 472 | end |
473 | local _exp_0 = tb | ||
474 | do | 473 | do |
474 | local _exp_0 = tb | ||
475 | local _tab_0 = "table" == type(_exp_0) | 475 | local _tab_0 = "table" == type(_exp_0) |
476 | if _tab_0 then | 476 | if _tab_0 then |
477 | local name, meta_field | 477 | local name, meta_field |
@@ -484,8 +484,23 @@ do | |||
484 | end | 484 | end |
485 | end | 485 | end |
486 | if meta_field ~= nil then | 486 | if meta_field ~= nil then |
487 | return print(name, meta_field) | 487 | print(name, meta_field) |
488 | end | 488 | end |
489 | end | 489 | end |
490 | end | 490 | end |
491 | end | 491 | end |
492 | do | ||
493 | local tb = { } | ||
494 | local _obj_0 = tb | ||
495 | do | ||
496 | local _tmp_0 = c() | ||
497 | local v2 = _obj_0[_tmp_0] | ||
498 | end | ||
499 | local v1 | ||
500 | do | ||
501 | local _obj_1 = getmetatable(_obj_0) | ||
502 | local _tmp_1 = a + b | ||
503 | v1 = _obj_1[_tmp_1] | ||
504 | end | ||
505 | end | ||
506 | return nil | ||
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp index 73b4ae9..9a9e2d6 100755 --- a/src/yuescript/yue_compiler.cpp +++ b/src/yuescript/yue_compiler.cpp | |||
@@ -59,7 +59,7 @@ namespace yue { | |||
59 | 59 | ||
60 | typedef std::list<std::string> str_list; | 60 | typedef std::list<std::string> str_list; |
61 | 61 | ||
62 | const std::string_view version = "0.15.1"sv; | 62 | const std::string_view version = "0.15.2"sv; |
63 | const std::string_view extension = "yue"sv; | 63 | const std::string_view extension = "yue"sv; |
64 | 64 | ||
65 | class YueCompilerImpl { | 65 | class YueCompilerImpl { |
@@ -1856,6 +1856,11 @@ private: | |||
1856 | } | 1856 | } |
1857 | } | 1857 | } |
1858 | if (destruct.inlineAssignment) { | 1858 | if (destruct.inlineAssignment) { |
1859 | if (!extraScope) { | ||
1860 | extraScope = true; | ||
1861 | temp.push_back(indent() + "do"s + nll(x)); | ||
1862 | pushScope(); | ||
1863 | } | ||
1859 | transformAssignment(destruct.inlineAssignment, temp); | 1864 | transformAssignment(destruct.inlineAssignment, temp); |
1860 | } | 1865 | } |
1861 | if (optionalDestruct) { | 1866 | if (optionalDestruct) { |