pkulchenko / MobDebug

Remote debugger for Lua.
Other
889 stars 192 forks source link

Wrong display (console and in site comment) when a table has two equal references #39

Closed aldus2 closed 6 years ago

aldus2 commented 6 years ago

I thought there was a problem with lua but in fact, everything works fine, it is only a question of wrong display of the console or of the in situ comments. Here is an example :

arrFunc={function(x) return 10*x end}
arrFunc[2]=arrFunc[1]

In the console in response to the question : arrFunc the answer : {function() --[[..skipped..]] end --[[function: 0x1371060]], nil --[[ref]]} --[[table: 0x1371150]] --[[incomplete output with shared/self-references skipped]] "nil" is incorrect. print(type(arrFunc[2]) gives "function" (rather strange for a nil) Moreover arrFunc2 gives 30 (again not in line with a "nil") but shows that it is working fine in lua.

The same phenomenon is true for another type of reference as a table, as in :

arrRef[1]=arrFunc
arrRef[2]=arrFunc

Version : 1.7 ; MobDebug 0.702 OS : Ubuntu LTS 14.04

pkulchenko commented 6 years ago

It's a feature; it's not possible to return table literal that includes shared or self-references, so the serializer replaces them with nil values and adds a comment to indicate that this is the case. You can use .dump method instead of .line, which is more verbose, but doesn't have this issue.