Comments (6)
Correction: looks like all keys are accessible with pairs(), and only non-negative are accessible via ipairs().
So this is only a little inconsistent, and may catch people if they either try to access the data using ipairs(), or if they try to use something that accesses tables in a generic way (e.g., the output above was produced via https://github.com/kikito/inspect.lua).
Thus, maybe not a bug, but a possible usability problem. I understand you may want to keep it the way it is, but I'll keep the report open just in case you have other thoughts.
from lua-protobuf.
Thanks for catching! But it’s really a bug. I will fix on next push (maybe tonight)
from lua-protobuf.
After a carefully review code and review your post, I'm very sorry I misunderstand your issue before :-(
Yes, it's not a bug. in Lua, { "one", "two" } is exactly just { [1] = "one", [2] = "two" }, and former is just a syntax sugar of latter.
and map's semantics indicate no order. means { [1] = "one", [2] = "two" } or { [2] = "two", [1] = "one" } are all legal result of decode.
from lua-protobuf.
Notice that's the semantics of Lua language. So I have no way to change this behavior :-)
just close, if you have new idea about map, you can re-open it. Thanks for feedback!
from lua-protobuf.
I agree that this is semantics of Lua and not really a bug (thanks for taking a look anyway! :).
It might still be worth mentioning this in the documentation that map keys, even when they are integers, should be accessed via 'pairs()' only, not ipairs() (since the latter might not give the full set of keys). I know it's just the language semantics, but it's one of the less obvious bits that might catch someone.
from lua-protobuf.
Okay I will change document :-)
from lua-protobuf.
Related Issues (20)
- symbol not found in flat namespace '_luaL_checkversion_' HOT 1
- 您好,请问oneof支持吗?lua里面怎么使用呢 HOT 1
- 当include_imports和unknow_import都为true时,会出现错误
- 希望支持 oneof 的 DefaultMessageDecoding HOT 1
- bad argument #1 to 'encode' (type 'Person' does not exists) HOT 8
- pb.so causes nginx to segfault HOT 4
- 循环引用场景下会导致stack overflow HOT 1
- pb.decode() 导致 out of memory HOT 1
- pb中uint64过长, 在decode时会被科学计数法 HOT 1
- pb.decode 问题。 HOT 1
- Option name expected
- Proto - JSON transcoder HOT 2
- nested message with default values regression HOT 1
- protobuf3 optional: configurable "optional_" prefix HOT 3
- pb.encode double/float 类型数据,在C++里ParseFromString会有问题。 HOT 2
- Decode to a temporary message to extract or change data
- Segfaults with gcc 13 and `-fstrict-aliasing` HOT 12
- 请问下java的.proto文件存在import引用其它文件如何加载 HOT 1
- Running on ESP32: load() function not working HOT 3
- what causes change in state? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lua-protobuf.