Skip to content

[Lua] Lua generator fails to generate correct code for simple singly nested table #8611

@poconnor-pilz

Description

@poconnor-pilz

The Lua generator will generate incorrect code for this schema:
table Customer { name: string; age: int; } table Sale { amount: int; customer: Customer; } root_type Sale;

It should generate:

Sale.AddCustomer = function(builder, customer) builder:PrependUOffsetTRelativeSlot(1, customer, 0) end

But instead it generates:
function Sale.AddCustomer(builder, customer) builder:PrependStructSlot(1, customer, 0) end

This will cause an error when trying to encode a sale:

"Tried to write a Struct at an Offset that is different from the current Offset of the Builder."

See this file for schema and lua test code:

luatest.zip

This bug is in the current windows release and in the head of the repo, specifically this git hash:

#5822c1c8

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions