diff options
| author | ruki <[email protected]> | 2024-01-10 00:52:47 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-01-10 00:52:47 +0800 |
| commit | 41b348d3cc68845e121aa489c4b20fb06026cfe8 (patch) | |
| tree | cb88d7d4cd12a282a41ff97c8faed3dbc8a32d15 /xmake/core/base | |
| parent | 95474ba466926b8a06bc0a610305d0ad3373c1d9 (diff) | |
fix test #4582
Diffstat (limited to 'xmake/core/base')
| -rw-r--r-- | xmake/core/base/scopeinfo.lua | 5 | ||||
| -rw-r--r-- | xmake/core/base/table.lua | 10 |
2 files changed, 11 insertions, 4 deletions
diff --git a/xmake/core/base/scopeinfo.lua b/xmake/core/base/scopeinfo.lua index a7bbb4a19..abe1d10fb 100644 --- a/xmake/core/base/scopeinfo.lua +++ b/xmake/core/base/scopeinfo.lua @@ -748,7 +748,10 @@ end -- clone a new instance from the current function _instance:clone() - return _instance.new(self:kind(), table.clone(self:info()), {interpreter = self:interpreter(), deduplicate = self._DEDUPLICATE, enable_filter = self._ENABLE_FILTER}) + return _instance.new(self:kind(), table.clone(self:info(), 3), { -- @note we need do deep clone + interpreter = self:interpreter(), + deduplicate = self._DEDUPLICATE, + enable_filter = self._ENABLE_FILTER}) end -- new a scope instance diff --git a/xmake/core/base/table.lua b/xmake/core/base/table.lua index f954596b8..fbef78a25 100644 --- a/xmake/core/base/table.lua +++ b/xmake/core/base/table.lua @@ -154,12 +154,16 @@ function table.append(array, ...) end -- clone table -function table.clone(self) +-- +-- @param depth e.g. shallow: 1, deep: -1 +-- +function table.clone(self, depth) + depth = depth or 1 local result = self - if type(self) == "table" then + if type(self) == "table" and depth > 0 then result = {} for k, v in pairs(self) do - result[k] = v + result[k] = table.clone(v, depth - 1) end end return result |
