# HG changeset patch # User jbe # Date 1420835543 -3600 # Node ID 48ee8826efbece068f67ffe8563abe874afebf83 # Parent b059efd8164950fc720fe1f1cde24ba210c05caa Correct handling of nil's in return tuples in execute.chunk{...} diff -r b059efd81649 -r 48ee8826efbe framework/env/execute/chunk.lua --- a/framework/env/execute/chunk.lua Fri Jan 09 04:54:50 2015 +0100 +++ b/framework/env/execute/chunk.lua Fri Jan 09 21:32:23 2015 +0100 @@ -9,11 +9,19 @@ params = params -- parameters to be returned by param.get(...) during execution } -This function loads and executes a lua file specified by a given path or constructs -a path to load from the module and chunk name. A chunk name should always begin with an underscore. All return values of the loaded and executed chunk are returned by this function as well. +This function loads and executes a lua file specified by a given path or constructs a path to load from the module and chunk name. A chunk name should always begin with an underscore. All return values of the loaded and executed chunk are returned by this function as well. --]]-- +local function pack_return_values(...) + local storage = {...} + storage.n = select("#", ...) +end + +local function unpack_return_values(storage) + return table.unpack(storage, 1, storage.n) +end + function execute.chunk(args) local file_path = args.file_path local app = args.app @@ -38,11 +46,11 @@ param.exchange(id, params) end - local result = {func()} + local result = pack_return_values(func()) if id or params then param.restore() end - return table.unpack(result) + return unpack_return_values(result) end