diff options
Diffstat (limited to 'script/vm/generic.lua')
-rw-r--r-- | script/vm/generic.lua | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/script/vm/generic.lua b/script/vm/generic.lua index 6462028e..544e11c9 100644 --- a/script/vm/generic.lua +++ b/script/vm/generic.lua @@ -11,11 +11,11 @@ local mt = {} mt.__index = mt mt.type = 'generic' ----@param source parser.object +---@param source vm.object? ---@param resolved? table<string, vm.node> ----@return parser.object | vm.node +---@return vm.object? local function cloneObject(source, resolved) - if not resolved then + if not resolved or not source then return source end if source.type == 'doc.generic.name' then @@ -121,8 +121,17 @@ function mt:resolve(uri, args) local protoNode = vm.compileNode(self.proto) local result = vm.createNode() for nd in protoNode:eachObject() do - local clonedNode = vm.compileNode(cloneObject(nd, resolved)) - result:merge(clonedNode) + if nd.type == 'global' then + ---@cast nd vm.global + result:merge(nd) + else + ---@cast nd -vm.global + local clonedObject = cloneObject(nd, resolved) + if clonedObject then + local clonedNode = vm.compileNode(clonedObject) + result:merge(clonedNode) + end + end end return result end |