You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This might not be a real bug report. It could easily be my fault in that I'm using pl.Map in the wrong way.
Consider the following code:
local Map=require"pl.Map"
local m=Map()
m:set("get", 5)
m:get("get")
This fails with the error
lua: /home/local/test/test.lua:48: attempt to call a number value (method 'get')
That's not surprising: the key "get" shadows the method. But does this mean that the map is now unusable (at least the "get" method) until "get" is deleted?
The text was updated successfully, but these errors were encountered:
Yes, it's a known problem, because the lookup cannot distinguish between the table and the metatable __index. Now we could make this bullet proof at the cost of performance - make __index a function and put some logic in it. For pl.Set I resolved the issue by having no methods.
Would it work for the Map table to store its key-value pairs in a separate table, like self.contents? That way the contents would never conflict with the methods.
This might not be a real bug report. It could easily be my fault in that I'm using pl.Map in the wrong way.
Consider the following code:
This fails with the error
That's not surprising: the key "get" shadows the method. But does this mean that the map is now unusable (at least the "get" method) until "get" is deleted?
The text was updated successfully, but these errors were encountered: