sol2ligo icon indicating copy to clipboard operation
sol2ligo copied to clipboard

struct init missing arguments should have default value

Open vird opened this issue 3 years ago • 0 comments

input: pragma solidity ^0.5.11;

contract Test {
  struct Person {
    address payable account;
    uint age;
    uint skill;
    uint bet;
    mapping (address => uint) referralRewards;
  }

  function test() public {
    Person memory p = Person(msg.sender, 30, 100, 0);
  }
}

output:

type test_Person is record
  account : address;
  age : nat;
  skill : nat;
  bet : nat;
  referralRewards : map(address, nat);
end;

type test_args is unit;
type state is unit;

const burn_address : address = ("tz1ZZZZZZZZZZZZZZZZZZZZZZZZZZZZNkiRg" : address);

const test_Person_default : test_Person = record [ account = burn_address;
  age = 0n;
  skill = 0n;
  bet = 0n;
  referralRewards = (map end : map(address, nat)) ];

type router_enum is
  | Test of test_args;

function test (const res__unit : unit) : (unit) is
  block {
    const p : test_Person = record [ account = Tezos.sender;
      age = 30n;
      skill = 100n;
      bet = 0n ];
  } with (unit);

function main (const action : router_enum; const self : state) : (list(operation) * state) is
  (case action of
  | Test(match_action) -> block {
    (* This function does nothing, but it's present in router *)
    const tmp : unit = test(unit);
  } with (((nil: list(operation)), self))
  end);

vird avatar Nov 10 '20 08:11 vird