Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Structs are being mistranslated in some cases #302

Open
machulen opened this issue Oct 1, 2020 · 0 comments
Open

Structs are being mistranslated in some cases #302

machulen opened this issue Oct 1, 2020 · 0 comments

Comments

@machulen
Copy link
Contributor

machulen commented Oct 1, 2020

Sample 1 - nested struct

pragma solidity ^0.5.0;

contract C {
	struct S {
		uint8 v;
	}
	struct T {
		S s;
	}
	function f() public {
		T memory t = T(S(25));
	}
}

Actual:

type c_S is record
  v : nat;
end;

type c_T is record
  s : t_S;
end;

type state is unit;

const c_S_default : c_S = record [ v = 0n ];

const c_T_default : c_T = record [ s = t_S_default ];

function f (const res__unit : unit) : (unit) is
  block {
    const t : c_T = record [ s = record [ v = 25n ] ];
  } with (unit);

Expected:

type c_S is record
  v : nat;
end;

type c_T is record
  s : c_S;
end;

type state is unit;

const c_S_default : c_S = record [ v = 0n ];

const c_T_default : c_T = record [ s = c_S_default ];

function f (const res__unit : unit) : (unit) is
  block {
    const t : c_T = record [ s = record [ v = 25n ] ];
  } with (unit);

Sample 2 - struct usage before definition

pragma solidity ^0.5.0;

contract C {
 function f() public {
   S memory s = S(25);
 }
 struct S {
   uint8 v;
 }
}

Actual: TypeError: Cannot read property 'scope' of undefined with a full stack trace.
Expected: some sensible Warning.

@machulen machulen changed the title Structs are being translated wrongly in some cases Structs are being mistranslated in some cases Oct 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant