Skip to content

feat: support casts in zkasm #1406

@DavePearce

Description

@DavePearce

The goal here is to support a notion of cast in zkasm, such as the following:

fn f(flag u1, val u64) -> (res u16) {
   if flag == 1 goto cast_u16
   res = 0
   return
cast_u16:
   res = u16(val)
   return
}

Currently, this can be implemented using the following:

fn f(flag u1, val u64) -> (res u16) {
   if flag == 1 goto cast_u16
   res = 0
   return
cast_u16:
   var tmp u48
   tmp, res = (u16) val
   if tmp != 0 goto exit_f
   return
exit_f:
   fail
}

Metadata

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