Restriction in msg.post , as designed?

Stumbled apon a restriction in msg.post today. Wonder if it is by design as it is differs from “normal” lua table handling.
Ok, here it goes:

local a = { foo = 1 } -- string as key, ok to use local b = { [{}] = 2 } -- table as key, ok to use msg.post( ".", "any_mess", a ) -- ok msg.post( ".", "any_mess", b ) -- error, keys in table must be of type number or string

Is this because it’s sent into the C part and cannot be handled?

1 Like

Yes, it’s a restriction in the messaging system. It’s generic and lua is simply one of the ways to interact with it (same system is used for intra-engine communication as well, where there is no lua present). The lua tables are serialised into an internal format, which does not support complex key-types.

1 Like

I’ll make sure this gets documented.

1 Like