Skip to content

assemblyscritt 0.28.2. Decoder.ts "Conversion from type 'i32' to 'u8' requires an explicit cast." #15

Open

Description

@avitsiuk

Upon compilation I receive a bunch of following errors:

ERROR AS200: Conversion from type 'i32' to 'u8' requires an explicit cast.
     :
 378 │ case Format.NIL:
     │      ~~~~~~~~~~
     └─ in ~lib/@wapc/as-msgpack/assembly/decoder.ts(378,12)

Error occurs on every switch statement that uses a value obtained from this.reader.getUint8();
For example:

readInt64(): i64 {
    const prefix = this.reader.getUint8();

    // ...
    switch (prefix) {
      case Format.INT8: // error
        return <i64>this.reader.getInt8();
      case Format.INT16: // error
        return <i64>this.reader.getInt16();
      // <rest of the code>

I managed to resolve the issue by adding explicit conversion:

switch (prefix as u32) {

In theory this conversion should be safe

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions