Skip to content

Instantly share code, notes, and snippets.

@okwme
Last active March 27, 2018 01:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save okwme/9b79bddfcf2e4a372f9bf5da30440384 to your computer and use it in GitHub Desktop.
Save okwme/9b79bddfcf2e4a372f9bf5da30440384 to your computer and use it in GitHub Desktop.
This demonstrates unexpected scope behavior in solidity when cloning structs.
pragma solidity ^0.4.19;
pragma experimental ABIEncoderV2;
contract Tester {
struct Foo {
bool stayFalse;
}
function Tester() public {
}
function runTest() public constant returns (bool) {
Foo memory foo;
return one(foo);
}
function one(Foo memory foo) public constant returns (bool){
Foo memory foobar;
foobar = two(foo);
return foo.stayFalse;
}
function two(Foo memory bar) public constant returns(Foo) {
bar.stayFalse = true;
return bar;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment