diff options
| author | Li Jin <dragon-fly@qq.com> | 2026-01-22 15:03:12 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2026-01-22 15:03:12 +0800 |
| commit | f1454bbbd13a71da2005ff789cde2da0e9eb81f6 (patch) | |
| tree | 37131187f4218dd3ebec049101c28a161e7ca289 /spec/outputs/with_scope_shadow.lua | |
| parent | 604a8e5e53cdc7391a502fcabf07e8f1cc2a778c (diff) | |
| download | yuescript-f1454bbbd13a71da2005ff789cde2da0e9eb81f6.tar.gz yuescript-f1454bbbd13a71da2005ff789cde2da0e9eb81f6.tar.bz2 yuescript-f1454bbbd13a71da2005ff789cde2da0e9eb81f6.zip | |
Diffstat (limited to 'spec/outputs/with_scope_shadow.lua')
| -rw-r--r-- | spec/outputs/with_scope_shadow.lua | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/outputs/with_scope_shadow.lua b/spec/outputs/with_scope_shadow.lua new file mode 100644 index 0000000..72abe95 --- /dev/null +++ b/spec/outputs/with_scope_shadow.lua | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | local target = { | ||
| 2 | val = 1, | ||
| 3 | add = function(self, n) | ||
| 4 | self.val = self.val + n | ||
| 5 | return self.val | ||
| 6 | end | ||
| 7 | } | ||
| 8 | local result | ||
| 9 | do | ||
| 10 | local val = 100 | ||
| 11 | add(2) | ||
| 12 | result = target | ||
| 13 | end | ||
| 14 | return print(result, target.val) | ||
