ab214a39
codegen: emit strict <Type>_fields / _oneofs constants for lazy view
Lazy-view callers passing a typo'd field name to :get / :has / :set / :clear / :which got `nil` back, indistinguishable from a legitimately- absent optional field. Failures surfaced as missing data downstream. Each generated message now exports a M.<Type>_fields table mapping each field name to itself (and M.<Type>_oneofs for oneof groups), wrapped by a new pb.field_names() helper that errors on unknown-key reads and on any write. Routing field-name arguments through these tables turns a typo into a load-time error at the read site. Eager _encode / _decode keep round-tripping plain Lua tables — the constants table is a lazy-view contract, documented in docs/api-modes.md. README and lazy_test.lua converted to the new pattern; three new tests cover typo / read-only / oneof-typo errors.
Eugene Blikh <bigbes@gmail.com> — 2026-05-16 19:28:13 UTC
Commit ab214a39023a13ef4c1e534589bdc0d20ff59ce4 —
view raw patch
Parent(s):
428ee1f6
| File | Status | + | − |
|---|---|---|---|
README.md
|
M | +7 | |
cmd/protoc-gen-tarantool/internal/gen/gen.go
|
M | +46 | |
docs/api-modes.md
|
M | +50 | -11 |
examples/expected/full/conformance/conformance_pb.lua
|
M | +39 | |
examples/expected/full/hello/hello_pb.lua
|
M | +51 | |
examples/expected/full/protobuf_test_messages/proto3/test_messages_proto3_pb.lua
|
M | +165 | |
examples/expected/runtime/conformance/conformance_pb.lua
|
M | +39 | |
examples/expected/runtime/hello/hello_pb.lua
|
M | +51 | |
examples/expected/runtime/protobuf_test_messages/proto3/test_messages_proto3_pb.lua
|
M | +165 | |
runtime/pb/init.lua
|
M | +17 | |
test/lazy_test.lua
|
M | +88 | -54 |