Skip to content

Object API packs arrays of structs in reverse order [TS, master] #7021

Closed as not planned
@AndyCampbellNvidia

Description

Generated TypeScript code in object-model API mostly does array reversal automatically to handle the backwards insertion order when packing, but for arrays-of-structs it does not.

Calls are generated to builder.createStructOffsetList with no reversal wrappers, and the function doesn't do any reversal logic internally.

The unit test code which should catch this failure is flawed, and does not verify correct ordering after pack/unpack round-trip (summing array elements is commutative):
https://github.com/google/flatbuffers/blob/master/tests/JavaScriptTest.js#L168

  let test_0 = monster.test4[0];
  let test_1 = monster.test4[1];
  assert.strictEqual(monster.test4.length, 2);
  assert.strictEqual(test_0.a + test_0.b + test_1.a + test_1.b, 100);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions