JairusSW / as-json

The only JSON library you'll need for AssemblyScript. SIMD enabled
MIT License
79 stars 15 forks source link

@json for map giving unreachable error #81

Closed spino17 closed 4 months ago

spino17 commented 4 months ago

When I am trying out this code:


import { JSON } from "json-as/assembly";

@json
class Yo {
  map: Map<string, u64>;

  constructor() {
    this.map = new Map();
  }
}

// WASM exported functions

export function mint(): void {
  let y = new Yo();
  y.map.set("bhavya", 3000);
}

it is throwing below error:

wasm://wasm/598cf7ca:1

RuntimeError: unreachable
    at wasm://wasm/598cf7ca:wasm-function[12]:0xd82
    at file:///<BASE-FILE-PATH>/examples/nft/tests/index.js:2:1

Node.js v20.15.0

but when I remove the json decorator like below:


// import { JSON } from "json-as/assembly"; // this package needs to be installed: https://www.npmjs.com/package/json-as, version: "^0.8.4"

// @json
class Yo {
  map: Map<string, u64>;

  constructor() {
    this.map = new Map();
  }
}

// WASM exported functions

export function mint(): void {
  let y = new Yo();
  y.map.set("yamini", 3000);
}

if works fine!

JairusSW commented 4 months ago

Hm, I'll take a look tomorrow

spino17 commented 4 months ago

Thanks @JairusSW for the response. Yeah sure, let me know if you need anything from my end. Thanks

spino17 commented 4 months ago

Thanks @JairusSW for fixing this so quickly. I wanted to know in which version will it be available?

JairusSW commented 4 months ago

Of course, v0.9.8b Live on NPM

spino17 commented 4 months ago

Yeah I installed that still there is some issue. I have opened up the issue with example.