Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remote console multi variables access bug #1149

Closed
robertlzj opened this issue Jun 16, 2022 · 2 comments
Closed

remote console multi variables access bug #1149

robertlzj opened this issue Jun 16, 2022 · 2 comments
Assignees

Comments

@robertlzj
Copy link

In Local console

>a,b,c=1,2,3 --'>': input
>a,c=nil
>b
2 --after input get v
>a,b,c
nil	2

Everything is correct.
But, in Remote console:

>a,b,c=1,2,3 --'>': input
>a,c=nil
>b
2 --after input get v
>a,b,c
nil --which should be 'nil, 2, nil' I think

Win10 x64, Lua 5.3 x32

@pkulchenko pkulchenko self-assigned this Jun 16, 2022
@pkulchenko
Copy link
Owner

pkulchenko commented Jun 16, 2022

The issue appears to be in the debugger and because it's using a table to collect the values, the result is Lua version-dependent (it's 5.1 in the local console and 5.3 in the remote console).

Can you check the following patch, as it fixes the issue for me:

diff --git a/lualibs/mobdebug/mobdebug.lua b/lualibs/mobdebug/mobdebug.lua
index 6d83fa28..36fa14c3 100644
--- a/lualibs/mobdebug/mobdebug.lua
+++ b/lualibs/mobdebug/mobdebug.lua
@@ -19,7 +19,7 @@ end)("os")
 
 local mobdebug = {
   _NAME = "mobdebug",
-  _VERSION = "0.802",
+  _VERSION = "0.803",
   _COPYRIGHT = "Paul Kulchenko",
   _DESCRIPTION = "Mobile Remote Debugger for the Lua programming language",
   port = os and os.getenv and tonumber((os.getenv("MOBDEBUG_PORT"))) or 8172,
@@ -731,9 +731,9 @@ local function stringify_results(params, status, ...)
   if params.nocode == nil then params.nocode = true end
   if params.comment == nil then params.comment = 1 end
 
-  local t = {...}
-  for i,v in pairs(t) do -- stringify each of the returned values
-    local ok, res = pcall(mobdebug.line, v, params)
+  local t = {}
+  for i = 1, select('#', ...) do -- stringify each of the returned values
+    local ok, res = pcall(mobdebug.line, select(i, ...), params)
     t[i] = ok and res or ("%q"):format(res):gsub("\010","n"):gsub("\026","\\026")
   end
   -- stringify table with all returned values

@robertlzj
Copy link
Author

Hi, it works as expected, thank you~

pkulchenko added a commit that referenced this issue Jun 17, 2022
…ixes #1149).

When an expression in Console returns multiple values with wholes
(`nil` values), not all values were shown and the results were
Lua version dependent. Now all values are shown for all versions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants