Skip to content

Instantly share code, notes, and snippets.

@sciguy16
Created February 3, 2017 13:44
Show Gist options
  • Save sciguy16/b12a625decccec7d0238a2179e1855da to your computer and use it in GitHub Desktop.
Save sciguy16/b12a625decccec7d0238a2179e1855da to your computer and use it in GitHub Desktop.
Contract for testing the order with which Solidity evaluates arguments to functions. This is explicitly declared to be unpredictable in the documentation.
pragma solidity ^0.4.2;
contract EvaluationOrder {
uint flag;
uint[] flags;
function EvaluationOrder(){
flag=1;
}
function callFunctionWithMultipleArguments(){
functionWithMultipleArguments(flagsPush(1),flagsPush(20),flagsPush(300),flagsPush(4000));
}
function functionWithMultipleArguments(uint a, uint b, uint c, uint d) returns (uint,uint,uint,uint){
return (a,b,c,d);
}
function flagsPush(uint x) returns (uint){
flags.push(flag+x);
flag = flag + 100000;
return x;
}
function getFlags() returns (uint[]){
return flags;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment