sol2ligo icon indicating copy to clipboard operation
sol2ligo copied to clipboard

Support index_access

Open KStasi opened this issue 5 years ago • 1 comments

example:

pragma solidity ^0.4.16;

contract BytesTest {
    function test10(bytes20 b0) public {
        bytes1 b6 = b0[1];
    }
}

KStasi avatar Feb 07 '20 09:02 KStasi

N.b. should be compiled as const b6 : bytes = Bytes.sub(1n, 2n, b0); for cast to int

function foo (const a : int ; const b : int) : int is
block { 
    const initial : int = 17;
    const packed : bytes = Bytes.pack(initial);
    const unpacked : option(int) = Bytes.unpack(packed);
    const value : int = case unpacked of 
      | None -> (failwith("cant unpack") : int)
      | Some(value) -> value
    end;
} with value

Also we need emulator tests for that

vird avatar Jul 20 '20 11:07 vird