|
kendric Newbie
Joined: 09 Dec 2009 Posts: 8
|
Posted: Thu Jan 14, 2010 9:53 pm
[3.1.2] 2 lua bugs |
1) If you store a lua table which has a single value, it appears that when you get it out later it becomes a string. For example I had stored:
tab={}
tab["blah"]=true
zs.var.myvar=tab
then in a later alias call
tab=zs.var.myvar
echo(typeof(tab)) --prints out string
echo(tab) -- prints out blah=true or something like that instead of {blah = true} or the equivelent
2) I was able to repro this, storing a lua table with circular refrences causes cmud to stop responding and crash. I see why this is bad but it prob should at least just error and not crash. |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Thu Jan 14, 2010 10:55 pm |
1) That is correct. Tables in Lua are converted to "String Lists" in CMUD. A String list is a set of strings separated by the | character. If there is just one value in the table, then you just get a simple string. So this is normal and cannot be changed, sorry.
2) Yep. There isn't any good way for me to trap this. The circular reference loop occurs within Lua itself, probably when you try to access it or print it. Lua is an external DLL to CMUD, so there isn't any way for CMUD to trap this and error. It's just one of those many "infinite loop" kinds of errors you need to try and avoid when programming.
Even in an expensive development system such as Delphi I can easily create a loop that freezes Delphi and requires me to stop the task from the Task Manager. I'm sure Microsoft Visual Studio has similar ways to hang it. Not much I can do. |
|
|
|
kendric Newbie
Joined: 09 Dec 2009 Posts: 8
|
Posted: Sat Jan 23, 2010 7:14 pm |
Ok. Thanks for your responses Zugg! I have another one but I will post a new message.
|
|
|
|
|
|