Merge remote-tracking branch 'origin/develop' into breaking

This commit is contained in:
chriseth
2020-07-08 09:37:14 +02:00
34 changed files with 278 additions and 74 deletions
+5 -3
View File
@@ -36,7 +36,8 @@ Binary representation:
Text representation:
/* "yul_stack_opt/input.sol":495:500 */
tag_1
jump(tag_2)
tag_2
jump // in
tag_1:
/* "yul_stack_opt/input.sol":425:500 */
pop
@@ -56,7 +57,8 @@ tag_1:
pop
/* "yul_stack_opt/input.sol":572:577 */
tag_3
jump(tag_2)
tag_2
jump // in
tag_3:
/* "yul_stack_opt/input.sol":502:577 */
pop
@@ -198,5 +200,5 @@ tag_5:
swap14
swap15
swap16
jump
jump // out
tag_4:
+24
View File
@@ -182,6 +182,30 @@ BOOST_AUTO_TEST_CASE(location_test)
checkAssemblyLocations(items, locations);
}
BOOST_AUTO_TEST_CASE(jump_type)
{
auto sourceCode = make_shared<CharStream>(R"(
contract C {
function f(uint a) public pure returns (uint t) {
assembly {
function g(x) -> y { if x { leave } y := 8 }
t := g(a)
}
}
}
)", "");
AssemblyItems items = compileContract(sourceCode);
string jumpTypes;
for (AssemblyItem const& item: items)
if (item.getJumpType() != AssemblyItem::JumpType::Ordinary)
jumpTypes += item.getJumpTypeAsString() + "\n";
BOOST_CHECK_EQUAL(jumpTypes, "[in]\n[out]\n[in]\n[out]\n");
}
BOOST_AUTO_TEST_SUITE_END()
} // end namespaces
@@ -0,0 +1,18 @@
contract C {
function f(bytes memory a, bytes calldata b, uint[] memory c)
external
pure
returns (uint, byte, uint, byte, uint, uint)
{
return (a.length, a[1], b.length, b[2], c.length, c[3]);
}
function g() public returns (uint, byte, uint, byte, uint, uint) {
uint[] memory x = new uint[](4);
x[3] = 7;
return this.f("abc", "def", x);
}
}
// ====
// compileViaYul: also
// ----
// g() -> 3, 0x6200000000000000000000000000000000000000000000000000000000000000, 3, 0x6600000000000000000000000000000000000000000000000000000000000000, 4, 7
@@ -0,0 +1,20 @@
pragma experimental ABIEncoderV2;
contract C {
function f(bytes memory a, bytes calldata b, uint[] memory c)
external
pure
returns (uint, byte, uint, byte, uint, uint)
{
return (a.length, a[1], b.length, b[2], c.length, c[3]);
}
function g() public returns (uint, byte, uint, byte, uint, uint) {
uint[] memory x = new uint[](4);
x[3] = 7;
return this.f("abc", "def", x);
}
}
// ====
// compileViaYul: also
// ----
// g() -> 3, 0x6200000000000000000000000000000000000000000000000000000000000000, 3, 0x6600000000000000000000000000000000000000000000000000000000000000, 4, 7
@@ -16,7 +16,7 @@ contract B is A {
function i(uint[] memory) public override payable {}
}
// ----
// DeclarationError 1686: (300-353): Function with same name and arguments defined twice.
// DeclarationError 1686: (358-419): Function with same name and arguments defined twice.
// DeclarationError 1686: (424-485): Function with same name and arguments defined twice.
// DeclarationError 1686: (490-546): Function with same name and arguments defined twice.
// DeclarationError 1686: (300-353): Function with same name and parameter types defined twice.
// DeclarationError 1686: (358-419): Function with same name and parameter types defined twice.
// DeclarationError 1686: (424-485): Function with same name and parameter types defined twice.
// DeclarationError 1686: (490-546): Function with same name and parameter types defined twice.
@@ -3,4 +3,4 @@ contract A {
function f(uint[] memory) internal pure {}
}
// ----
// DeclarationError 1686: (17-61): Function with same name and arguments defined twice.
// DeclarationError 1686: (17-61): Function with same name and parameter types defined twice.
@@ -3,4 +3,4 @@ contract test {
event A(uint i);
}
// ----
// DeclarationError 5883: (20-36): Event with same name and arguments defined twice.
// DeclarationError 5883: (20-36): Event with same name and parameter types defined twice.
@@ -3,4 +3,4 @@ contract test {
event A(uint i) anonymous;
}
// ----
// DeclarationError 5883: (20-36): Event with same name and arguments defined twice.
// DeclarationError 5883: (20-36): Event with same name and parameter types defined twice.
@@ -3,4 +3,4 @@ contract test {
event A(uint indexed i);
}
// ----
// DeclarationError 5883: (20-36): Event with same name and arguments defined twice.
// DeclarationError 5883: (20-36): Event with same name and parameter types defined twice.
@@ -3,4 +3,4 @@ contract C {
function test(uint a) external {}
}
// ----
// DeclarationError 1686: (17-66): Function with same name and arguments defined twice.
// DeclarationError 1686: (17-66): Function with same name and parameter types defined twice.
@@ -6,4 +6,4 @@ contract test {
function fun(uint a) public returns(uint r) { return a; }
}
// ----
// DeclarationError 1686: (189-246): Function with same name and arguments defined twice.
// DeclarationError 1686: (189-246): Function with same name and parameter types defined twice.
@@ -3,4 +3,4 @@ contract test {
function fun() public { }
}
// ----
// DeclarationError 1686: (20-45): Function with same name and arguments defined twice.
// DeclarationError 1686: (20-45): Function with same name and parameter types defined twice.
@@ -13,12 +13,12 @@ object "Contract" {
// tag_2:
// /* "source":46:48 */
// tag_3:
// jump
// jump // out
// /* "source":53:68 */
// tag_4:
// /* "source":66:68 */
// tag_5:
// jump
// jump // out
// tag_1:
// /* "source":83:84 */
// 0x01
@@ -28,4 +28,4 @@ object "Contract" {
// sstore
// Bytecode: 6009565b5b565b5b565b6001600055
// Opcodes: PUSH1 0x9 JUMP JUMPDEST JUMPDEST JUMP JUMPDEST JUMPDEST JUMP JUMPDEST PUSH1 0x1 PUSH1 0x0 SSTORE
// SourceMappings: 33:15:0:-:0;;;46:2;;53:15;66:2;;;83:1;80;73:12
// SourceMappings: 33:15:0:-:0;;;46:2;:::o;53:15::-;66:2;:::o;:::-;83:1;80;73:12
+64
View File
@@ -0,0 +1,64 @@
object "Contract" {
code {
function f() { g(1) }
function g(x) { if x { leave } g(add(x, 2)) }
g(1)
}
}
// ----
// Assembly:
// /* "source":33:54 */
// jump(tag_1)
// tag_2:
// /* "source":48:52 */
// tag_4
// /* "source":50:51 */
// 0x01
// /* "source":48:52 */
// tag_5
// jump // in
// tag_4:
// /* "source":46:54 */
// tag_3:
// jump // out
// /* "source":59:104 */
// tag_5:
// /* "source":78:79 */
// dup1
// /* "source":75:77 */
// iszero
// tag_7
// jumpi
// /* "source":82:87 */
// jump(tag_6)
// /* "source":75:77 */
// tag_7:
// /* "source":90:102 */
// tag_8
// /* "source":99:100 */
// 0x02
// /* "source":96:97 */
// dup3
// /* "source":92:101 */
// add
// /* "source":90:102 */
// tag_5
// jump // in
// tag_8:
// /* "source":73:104 */
// tag_6:
// pop
// jump // out
// tag_1:
// /* "source":109:113 */
// tag_9
// /* "source":111:112 */
// 0x01
// /* "source":109:113 */
// tag_5
// jump // in
// tag_9:
// Bytecode: 6025565b600b6001600e565b5b565b80156017576022565b602160028201600e565b5b50565b602d6001600e565b
// Opcodes: PUSH1 0x25 JUMP JUMPDEST PUSH1 0xB PUSH1 0x1 PUSH1 0xE JUMP JUMPDEST JUMPDEST JUMP JUMPDEST DUP1 ISZERO PUSH1 0x17 JUMPI PUSH1 0x22 JUMP JUMPDEST PUSH1 0x21 PUSH1 0x2 DUP3 ADD PUSH1 0xE JUMP JUMPDEST JUMPDEST POP JUMP JUMPDEST PUSH1 0x2D PUSH1 0x1 PUSH1 0xE JUMP JUMPDEST
// SourceMappings: 33:21:0:-:0;;;48:4;50:1;48:4;:::i;:::-;46:8;:::o;59:45::-;78:1;75:2;;;82:5;;75:2;90:12;99:1;96;92:9;90:12;:::i;:::-;73:31;;:::o;:::-;109:4;111:1;109:4;:::i;:::-
@@ -0,0 +1,10 @@
{
function f() -> a, b {}
function g() -> a, b, c {}
let x, y
x, x := f()
y, x, y := g()
}
// ----
// DeclarationError 9005: (70-81): Variable x occurs multiple times on the left-hand side of the assignment.
// DeclarationError 9005: (84-98): Variable y occurs multiple times on the left-hand side of the assignment.
@@ -0,0 +1,6 @@
{
function f() -> a, b {}
let x, x := f()
}
// ----
// DeclarationError 1395: (30-45): Variable name x already taken in this scope.