nearprotocol / assemblyscript

A TypeScript to WebAssembly compiler 🚀
https://assemblyscript.org
Apache License 2.0
8 stars 1 forks source link

Nested structures do not work. (array of array of classes) #18

Closed janedegtiareva closed 5 years ago

janedegtiareva commented 5 years ago

fiddle that reproes https://studio.nearprotocol.com/?f=opapxvcfg

fails on assert(name == null); in the following code


      buffer: Uint8Array;
      decoder: JSONDecoder<__near_JSONHandler_Array_Array_GameCellData>;
      handledRoot: boolean = false;
      value: Array<Array<wrapped_GameCellData>> = new Array<Array<wrapped_GameCellData>>();
pushObject(name: string): bool {
        this.value.push(<Array<GameCellData>>__near_decode_Array_GameCellData(this.buffer, this.decoder.state));
        return false;
      }
      pushArray(name: string): bool {
        assert(name == null);
        if (!this.handledRoot) {
          this.handledRoot = true;
          return true;
        }
        this.value.push(<Array<GameCellData>>__near_decode_Array_GameCellData(this.buffer, this.decoder.state));
        return false;
      }```
janedegtiareva commented 5 years ago

This is the smallest fiddle that I could get to repro the bug https://studio.nearprotocol.com/?f=rw4kghq7a

vgrichina commented 5 years ago

Updated for latest NEARLib https://studio.nearprotocol.com/?f=i98us2ahd

vgrichina commented 5 years ago

This got somewhat blocked by https://github.com/AssemblyScript/assemblyscript/issues/473 (https://github.com/AssemblyScript/assemblyscript/issues/429 to be more specific).

I'll try to restructure tests to get around this though.

vgrichina commented 5 years ago

Actual bug was with null handling delaying error significantly: https://github.com/AssemblyScript/assemblyscript/issues/507

vgrichina commented 5 years ago

Closing, tests are here https://github.com/nearprotocol/assemblyscript/pull/22