mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge remote-tracking branch 'origin/develop' into breaking
This commit is contained in:
@@ -45,7 +45,7 @@ object "object" {
|
||||
|
||||
|
||||
Binary representation:
|
||||
0061736d0100000001160460000060017e017e60057e7e7e7e7e0060027f7f0002190108657468657265756d0c73746f7261676553746f7265000303060500010101020503010001060100071102066d656d6f72790200046d61696e00010acd01052b01017e0240420021004200200020002000200010054220200020002000420110054200a74220a710000b0b1f01017e024020004208864280fe0383200042088842ff01838421010b20010b1e01027e02402000100242108621022002200042108810028421010b20010b1e01027e02402000100342208621022002200042208810038421010b20010b4101007e02402000a7200110043703002000a74208a76aada7200210043703002000a74210a76aada7200310043703002000a74218a76aada7200410043703000b0b
|
||||
0061736d0100000001160460000060017e017e60057e7e7e7e7e0060027f7f0002190108657468657265756d0c73746f7261676553746f7265000303060500010101020503010001060100071102066d656d6f72790200046d61696e00010acb01052b01017e0240420021004200200020002000200010054220200020002000420110054200a74220a710000b0b1f01017e024020004208864280fe0383200042088842ff01838421010b20010b1e01027e02402000100242108621022002200042108810028421010b20010b1e01027e02402000100342208621022002200042208810038421010b20010b3f0002402000a7200110043700002000a74208a76aada7200210043700002000a74210a76aada7200310043700002000a74218a76aada7200410043700000b0b
|
||||
|
||||
Text representation:
|
||||
(module
|
||||
|
||||
@@ -154,7 +154,7 @@ object "object" {
|
||||
|
||||
|
||||
Binary representation:
|
||||
0061736d0100000001480a60000060017e017e60027e7e017e60037e7e7e017e60047e7e7e7e017e60057e7e7e7e7e0060087e7e7e7e7e7e7e7e0060087e7e7e7e7e7e7e7e017e60027f7f0060037f7f7f0002310208657468657265756d0c73746f7261676553746f7265000808657468657265756d0c63616c6c44617461436f70790009030e0d0003070407020704010101050605030100010610037e0142000b7e0142000b7e0142000b071102066d656d6f72790200046d61696e00020aa9090df302011f7e02404200210002402000200020002000100921012300210223012103230221040b2001210520022106200321072004210842012109200020008420002009848450ada745ada745ad210a02400340200aa745ad500d01024002402005200620072008200020002000420a1008210b2300210c2301210d2302210e0b0240200b200c200d200e1005210f2300211023012111230221120b200f20108420112012848450ada745ad42005204400c030b024020052006200720082000200020004202100621132300211423012115230221160b201320148420152016848450ada745ad42005204400c030b0240200520062007200820002000200042041006211723002118230121192302211a0b20172018842019201a848450ada745ad42005204400c010b0b0240200520062007200820002000200020091004211b2300211c2301211d2302211e0b201b2105201c2106201d2107201e21080c000b0b20002000200020002005200620072008100e0b0b2f01037e0240200020017c2105200520027c21032005200054ada72003200554ada772ada7ad21040b2004240020030b72010b7e0240200320077c210c200c42007c210b024020022006200c200354ada7200b200c54ada772ada7ad1003210d2300210e0b200d210a024020012005200e1003210f230021100b200f2109024020002004201010032111230021120b201121080b20092400200a2401200b240220080b2601047e0240200020018420022003848450ada7ad21070b20052400200624012007240220040b4901047e02402000200451ad42005204402001200551ad42005204402002200651ad42005204402003200751ad42005204404201210b0b0b0b0b0b20092400200a2401200b240220080b2d01027e024002402000200154ad21032003420151044042ffffffff0f2102052000200152ad21020b0b0b20020b960101087e02404200210c0240200020041007210d200d42005104400240200120051007210e200e42005104400240200220061007210f200f42005104402003200754ad210c05200f42015104404200210c054201210c0b0b0b05200e42015104404200210c054201210c0b0b0b05200d42015104404200210c054201210c0b0b0b200ca7ad210b0b20092400200a2401200b240220080b8f0101087e02404200200020018420028452ad4200520440000b4200200342208852ad4200520440000b4200a72003a7ada74220a710014200a7290300100c21084200a74208a76aada7290300100c21094200a74210a76aada7290300100c210a4200a74218a76aada7290300100c210b2008210420092105200a2106200b21070b20052400200624012007240220040b1f01017e024020004208864280fe0383200042088842ff01838421010b20010b1e01027e02402000100a421086210220022000421088100a8421010b20010b1e01027e02402000100b422086210220022000422088100b8421010b20010b4101007e02402000a72001100c3703002000a74208a76aada72002100c3703002000a74210a76aada72003100c3703002000a74218a76aada72004100c3703000b0b2701007e024042002000200120022003100d42202004200520062007100d4200a74220a710000b0b
|
||||
0061736d0100000001480a60000060017e017e60027e7e017e60037e7e7e017e60047e7e7e7e017e60057e7e7e7e7e0060087e7e7e7e7e7e7e7e0060087e7e7e7e7e7e7e7e017e60027f7f0060037f7f7f0002310208657468657265756d0c73746f7261676553746f7265000808657468657265756d0c63616c6c44617461436f70790009030e0d0003070407020704010101050605030100010610037e0142000b7e0142000b7e0142000b071102066d656d6f72790200046d61696e00020aa5090df302011f7e02404200210002402000200020002000100921012300210223012103230221040b2001210520022106200321072004210842012109200020008420002009848450ada745ada745ad210a02400340200aa745ad500d01024002402005200620072008200020002000420a1008210b2300210c2301210d2302210e0b0240200b200c200d200e1005210f2300211023012111230221120b200f20108420112012848450ada745ad42005204400c030b024020052006200720082000200020004202100621132300211423012115230221160b201320148420152016848450ada745ad42005204400c030b0240200520062007200820002000200042041006211723002118230121192302211a0b20172018842019201a848450ada745ad42005204400c010b0b0240200520062007200820002000200020091004211b2300211c2301211d2302211e0b201b2105201c2106201d2107201e21080c000b0b20002000200020002005200620072008100e0b0b2f01037e0240200020017c2105200520027c21032005200054ada72003200554ada772ada7ad21040b2004240020030b72010b7e0240200320077c210c200c42007c210b024020022006200c200354ada7200b200c54ada772ada7ad1003210d2300210e0b200d210a024020012005200e1003210f230021100b200f2109024020002004201010032111230021120b201121080b20092400200a2401200b240220080b2601047e0240200020018420022003848450ada7ad21070b20052400200624012007240220040b4901047e02402000200451ad42005204402001200551ad42005204402002200651ad42005204402003200751ad42005204404201210b0b0b0b0b0b20092400200a2401200b240220080b2d01027e024002402000200154ad21032003420151044042ffffffff0f2102052000200152ad21020b0b0b20020b960101087e02404200210c0240200020041007210d200d42005104400240200120051007210e200e42005104400240200220061007210f200f42005104402003200754ad210c05200f42015104404200210c054201210c0b0b0b05200e42015104404200210c054201210c0b0b0b05200d42015104404200210c054201210c0b0b0b200ca7ad210b0b20092400200a2401200b240220080b8f0101087e02404200200020018420028452ad4200520440000b4200200342208852ad4200520440000b4200a72003a7ada74220a710014200a7290000100c21084200a74208a76aada7290000100c21094200a74210a76aada7290000100c210a4200a74218a76aada7290000100c210b2008210420092105200a2106200b21070b20052400200624012007240220040b1f01017e024020004208864280fe0383200042088842ff01838421010b20010b1e01027e02402000100a421086210220022000421088100a8421010b20010b1e01027e02402000100b422086210220022000422088100b8421010b20010b3f0002402000a72001100c3700002000a74208a76aada72002100c3700002000a74210a76aada72003100c3700002000a74218a76aada72004100c3700000b0b2500024042002000200120022003100d42202004200520062007100d4200a74220a710000b0b
|
||||
|
||||
Text representation:
|
||||
(module
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
--yul --yul-dialect ewasm --machine ewasm
|
||||
@@ -0,0 +1 @@
|
||||
Warning: Yul is still experimental. Please use the output with care.
|
||||
@@ -0,0 +1,8 @@
|
||||
object "object" {
|
||||
code {
|
||||
function main()
|
||||
{
|
||||
i64.store8(0x01:i32, 42:i64)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
|
||||
======= wasm_to_wasm_memory_instructions_alignment/input.yul (Ewasm) =======
|
||||
|
||||
Pretty printed source:
|
||||
object "object" {
|
||||
code {
|
||||
function main()
|
||||
{ i64.store8(0x01:i32, 42) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binary representation:
|
||||
0061736d01000000010401600000020100030201000503010001060100071102066d656d6f72790200046d61696e00000a0f010d0002404201a7422a3c00000b0b
|
||||
|
||||
Text representation:
|
||||
(module
|
||||
(memory $memory (export "memory") 1)
|
||||
(export "main" (func $main))
|
||||
|
||||
(func $main
|
||||
(block $label_
|
||||
(i64.store8 (i32.wrap_i64 (i64.const 1)) (i64.const 42))
|
||||
)
|
||||
)
|
||||
|
||||
)
|
||||
@@ -31,14 +31,14 @@
|
||||
{
|
||||
"id": 4,
|
||||
"nodeType": "Block",
|
||||
"src": "42:48:1",
|
||||
"src": "42:58:1",
|
||||
"statements":
|
||||
[
|
||||
{
|
||||
"AST":
|
||||
{
|
||||
"nodeType": "YulBlock",
|
||||
"src": "61:23:1",
|
||||
"src": "61:33:1",
|
||||
"statements":
|
||||
[
|
||||
{
|
||||
@@ -48,11 +48,29 @@
|
||||
"body":
|
||||
{
|
||||
"nodeType": "YulBlock",
|
||||
"src": "80:2:1",
|
||||
"src": "79:2:1",
|
||||
"statements": []
|
||||
},
|
||||
"nodeType": "YulCase",
|
||||
"src": "72:10:1",
|
||||
"src": "72:9:1",
|
||||
"value":
|
||||
{
|
||||
"kind": "number",
|
||||
"nodeType": "YulLiteral",
|
||||
"src": "77:1:1",
|
||||
"type": "",
|
||||
"value": "0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"body":
|
||||
{
|
||||
"nodeType": "YulBlock",
|
||||
"src": "90:2:1",
|
||||
"statements": []
|
||||
},
|
||||
"nodeType": "YulCase",
|
||||
"src": "82:10:1",
|
||||
"value": "default"
|
||||
}
|
||||
],
|
||||
@@ -65,7 +83,7 @@
|
||||
"value": "0"
|
||||
},
|
||||
"nodeType": "YulSwitch",
|
||||
"src": "63:19:1"
|
||||
"src": "63:29:1"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -73,7 +91,7 @@
|
||||
"externalReferences": [],
|
||||
"id": 3,
|
||||
"nodeType": "InlineAssembly",
|
||||
"src": "52:32:1"
|
||||
"src": "52:42:1"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -99,15 +117,15 @@
|
||||
"src": "42:0:1"
|
||||
},
|
||||
"scope": 6,
|
||||
"src": "17:73:1",
|
||||
"src": "17:83:1",
|
||||
"stateMutability": "view",
|
||||
"virtual": false,
|
||||
"visibility": "public"
|
||||
}
|
||||
],
|
||||
"scope": 7,
|
||||
"src": "0:92:1"
|
||||
"src": "0:102:1"
|
||||
}
|
||||
],
|
||||
"src": "0:93:1"
|
||||
"src": "0:103:1"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
contract C {
|
||||
function g() view public {
|
||||
assembly { switch 0 default {} }
|
||||
assembly { switch 0 case 0 {} default {} }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,30 +91,30 @@
|
||||
[
|
||||
null
|
||||
],
|
||||
"operations": "{\n switch 0\n default { }\n}"
|
||||
"operations": "{\n switch 0\n case 0 { }\n default { }\n}"
|
||||
},
|
||||
"children": [],
|
||||
"id": 3,
|
||||
"name": "InlineAssembly",
|
||||
"src": "52:32:1"
|
||||
"src": "52:42:1"
|
||||
}
|
||||
],
|
||||
"id": 4,
|
||||
"name": "Block",
|
||||
"src": "42:48:1"
|
||||
"src": "42:58:1"
|
||||
}
|
||||
],
|
||||
"id": 5,
|
||||
"name": "FunctionDefinition",
|
||||
"src": "17:73:1"
|
||||
"src": "17:83:1"
|
||||
}
|
||||
],
|
||||
"id": 6,
|
||||
"name": "ContractDefinition",
|
||||
"src": "0:92:1"
|
||||
"src": "0:102:1"
|
||||
}
|
||||
],
|
||||
"id": 7,
|
||||
"name": "SourceUnit",
|
||||
"src": "0:93:1"
|
||||
"src": "0:103:1"
|
||||
}
|
||||
|
||||
@@ -314,9 +314,17 @@ BOOST_AUTO_TEST_CASE(switch_duplicate_case)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(switch_invalid_expression)
|
||||
{
|
||||
CHECK_PARSE_ERROR("{ switch {} default {} }", ParserError, "Literal or identifier expected.");
|
||||
CHECK_PARSE_ERROR("{ switch mload default {} }", ParserError, "Expected '(' but got reserved keyword 'default'");
|
||||
CHECK_PARSE_ERROR("{ switch mstore(1, 1) default {} }", TypeError, "Expected expression to evaluate to one value, but got 0 values instead.");
|
||||
CHECK_PARSE_ERROR("{ switch {} case 1 {} default {} }", ParserError, "Literal or identifier expected.");
|
||||
CHECK_PARSE_ERROR(
|
||||
"{ switch mload case 1 {} default {} }",
|
||||
ParserError,
|
||||
"Expected '(' but got reserved keyword 'case'"
|
||||
);
|
||||
CHECK_PARSE_ERROR(
|
||||
"{ switch mstore(1, 1) case 1 {} default {} }",
|
||||
TypeError,
|
||||
"Expected expression to evaluate to one value, but got 0 values instead."
|
||||
);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(switch_default_before_case)
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
contract C {
|
||||
function to_little_endian_64(uint64 value) public pure returns (bytes memory ret) {
|
||||
ret = new bytes(8);
|
||||
bytes8 bytesValue = bytes8(value);
|
||||
// Byteswapping during copying to bytes.
|
||||
ret[0] = bytesValue[7];
|
||||
ret[1] = bytesValue[6];
|
||||
ret[2] = bytesValue[5];
|
||||
ret[3] = bytesValue[4];
|
||||
ret[4] = bytesValue[3];
|
||||
ret[5] = bytesValue[2];
|
||||
ret[6] = bytesValue[1];
|
||||
ret[7] = bytesValue[0];
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// to_little_endian_64(uint64): 0 -> 0x20, 8, 0x00
|
||||
// to_little_endian_64(uint64): 0x0102030405060708 -> 0x20, 8, 0x0807060504030201000000000000000000000000000000000000000000000000
|
||||
@@ -0,0 +1,29 @@
|
||||
contract C {
|
||||
struct Y {
|
||||
uint a;
|
||||
uint b;
|
||||
}
|
||||
mapping(uint256 => Y)[] public m;
|
||||
mapping(uint256 => Y)[3] public n;
|
||||
constructor() public {
|
||||
m.push();
|
||||
m.push();
|
||||
m[1][0].a = 1;
|
||||
m[1][0].b = 2;
|
||||
m[1][1].a = 3;
|
||||
m[1][1].b = 4;
|
||||
n[1][0].a = 7;
|
||||
n[1][0].b = 8;
|
||||
n[1][1].a = 9;
|
||||
n[1][1].b = 10;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// m(uint256,uint256): 0, 0 -> 0x00, 0x00
|
||||
// m(uint256,uint256): 1, 0 -> 1, 2
|
||||
// m(uint256,uint256): 1, 1 -> 3, 4
|
||||
// m(uint256,uint256): 1, 2 -> 0x00, 0x00
|
||||
// n(uint256,uint256): 0, 0 -> 0x00, 0x00
|
||||
// n(uint256,uint256): 1, 0 -> 7, 8
|
||||
// n(uint256,uint256): 1, 1 -> 9, 0x0a
|
||||
// n(uint256,uint256): 1, 2 -> 0x00, 0x00
|
||||
@@ -0,0 +1,27 @@
|
||||
contract C {
|
||||
struct Y {
|
||||
uint a;
|
||||
uint b;
|
||||
}
|
||||
mapping(uint256 => Y[]) public m;
|
||||
mapping(uint256 => Y[3]) public n;
|
||||
constructor() public {
|
||||
m[1].push().a = 1;
|
||||
m[1][0].b = 2;
|
||||
m[1].push().a = 3;
|
||||
m[1][1].b = 4;
|
||||
n[1][0].a = 7;
|
||||
n[1][0].b = 8;
|
||||
n[1][1].a = 9;
|
||||
n[1][1].b = 10;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// m(uint256,uint256): 0, 0 -> FAILURE
|
||||
// m(uint256,uint256): 1, 0 -> 1, 2
|
||||
// m(uint256,uint256): 1, 1 -> 3, 4
|
||||
// m(uint256,uint256): 1, 2 -> FAILURE
|
||||
// n(uint256,uint256): 0, 0 -> 0x00, 0x00
|
||||
// n(uint256,uint256): 1, 0 -> 7, 8
|
||||
// n(uint256,uint256): 1, 1 -> 9, 0x0a
|
||||
// n(uint256,uint256): 1, 2 -> 0x00, 0x00
|
||||
@@ -0,0 +1,18 @@
|
||||
contract C {
|
||||
mapping(string => uint8[3]) public x;
|
||||
constructor() public {
|
||||
x["abc"][0] = 1;
|
||||
x["abc"][2] = 3;
|
||||
x["abc"][1] = 2;
|
||||
x["def"][1] = 9;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// x(string,uint256): 0x40, 0, 3, "abc" -> 1
|
||||
// x(string,uint256): 0x40, 1, 3, "abc" -> 2
|
||||
// x(string,uint256): 0x40, 2, 3, "abc" -> 3
|
||||
// x(string,uint256): 0x40, 0, 3, "def" -> 0x00
|
||||
// x(string,uint256): 0x40, 1, 3, "def" -> 9
|
||||
// x(string,uint256): 0x40, 2, 3, "def" -> 0x00
|
||||
@@ -0,0 +1,18 @@
|
||||
contract C {
|
||||
struct S {
|
||||
uint a;
|
||||
bytes b;
|
||||
mapping(uint => uint) c;
|
||||
uint[] d;
|
||||
}
|
||||
uint shifter;
|
||||
S public s;
|
||||
constructor() public {
|
||||
s.a = 7;
|
||||
s.b = "abc";
|
||||
s.c[0] = 9;
|
||||
s.d.push(10);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// s() -> 7, 0x40, 3, 0x6162630000000000000000000000000000000000000000000000000000000000
|
||||
@@ -0,0 +1,23 @@
|
||||
pragma experimental SMTChecker;
|
||||
|
||||
contract C {
|
||||
uint[][] a;
|
||||
uint[][][] c;
|
||||
uint[] d;
|
||||
function f() public {
|
||||
a.push();
|
||||
uint[] storage b = a[0];
|
||||
c[0][0][0] = 12;
|
||||
d[5] = 7;
|
||||
b.push(8);
|
||||
assert(a[0].length == 0);
|
||||
// Safe but knowledge about `c` is erased because `b` could be pointing to `c[x][y]`.
|
||||
assert(c[0][0][0] == 12);
|
||||
// Safe but knowledge about `d` is erased because `b` could be pointing to `d`.
|
||||
assert(d[5] == 7);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (193-217): Assertion violation happens here
|
||||
// Warning: (309-333): Assertion violation happens here
|
||||
// Warning: (419-436): Assertion violation happens here
|
||||
@@ -0,0 +1,12 @@
|
||||
pragma experimental SMTChecker;
|
||||
contract test {
|
||||
function f() internal pure {
|
||||
ufixed a = uint64(1) + ufixed(2);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (80-88): Unused local variable.
|
||||
// Warning: (91-100): Type conversion is not yet fully supported and might yield false positives.
|
||||
// Warning: (103-112): Type conversion is not yet fully supported and might yield false positives.
|
||||
// Warning: (91-112): Underflow (resulting value less than 0) happens here
|
||||
// Warning: (91-112): Overflow (resulting value larger than 2**256 - 1) happens here
|
||||
@@ -0,0 +1,8 @@
|
||||
pragma experimental SMTChecker;
|
||||
contract C {
|
||||
fixed[] b;
|
||||
function f() internal { b[0] += 1; }
|
||||
}
|
||||
// ----
|
||||
// Warning: (84-93): Underflow (resulting value less than 0) happens here
|
||||
// Warning: (84-93): Overflow (resulting value larger than 2**256 - 1) happens here
|
||||
@@ -0,0 +1,6 @@
|
||||
pragma experimental SMTChecker;
|
||||
contract C {
|
||||
function f3() public pure {
|
||||
((, ), ) = ((7, 8), 9);
|
||||
}
|
||||
}
|
||||
+2
-10
@@ -1,15 +1,7 @@
|
||||
contract C {
|
||||
struct S { bool f; }
|
||||
S s;
|
||||
function f(uint256 a) internal pure {
|
||||
S storage c;
|
||||
assembly {
|
||||
switch a
|
||||
default { c_slot := s_slot }
|
||||
}
|
||||
c;
|
||||
}
|
||||
function g(bool flag) internal pure {
|
||||
function f(bool flag) internal pure {
|
||||
S storage c;
|
||||
assembly {
|
||||
switch flag
|
||||
@@ -18,7 +10,7 @@ contract C {
|
||||
}
|
||||
c;
|
||||
}
|
||||
function h(uint256 a) internal pure {
|
||||
function g(uint256 a) internal pure {
|
||||
S storage c;
|
||||
assembly {
|
||||
switch a
|
||||
|
||||
@@ -1,20 +1,14 @@
|
||||
contract C {
|
||||
struct S { bool f; }
|
||||
S s;
|
||||
function f(uint256 a) internal pure returns (S storage c) {
|
||||
assembly {
|
||||
switch a
|
||||
default { c_slot := s_slot }
|
||||
}
|
||||
}
|
||||
function g(bool flag) internal pure returns (S storage c) {
|
||||
function f(bool flag) internal pure returns (S storage c) {
|
||||
assembly {
|
||||
switch flag
|
||||
case 0 { c_slot := s_slot }
|
||||
default { c_slot := s_slot }
|
||||
}
|
||||
}
|
||||
function h(uint256 a) internal pure returns (S storage c) {
|
||||
function g(uint256 a) internal pure returns (S storage c) {
|
||||
assembly {
|
||||
switch a
|
||||
case 0 { revert(0, 0) }
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
contract C {
|
||||
struct S { bool f; }
|
||||
S s;
|
||||
function f(uint256 a) internal pure returns (S storage c) {
|
||||
assembly {
|
||||
switch a
|
||||
default { c_slot := s_slot }
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (142-195): "switch" statement with only a default case.
|
||||
@@ -87,12 +87,12 @@ pair<shared_ptr<Block>, shared_ptr<yul::AsmAnalysisInfo>> yul::test::parse(
|
||||
shared_ptr<Object> parserResult = yul::ObjectParser(errorReporter, _dialect).parse(scanner, false);
|
||||
if (!parserResult)
|
||||
return {};
|
||||
if (!parserResult->code || !errorReporter.errors().empty())
|
||||
if (!parserResult->code || errorReporter.hasErrors())
|
||||
return {};
|
||||
shared_ptr<AsmAnalysisInfo> analysisInfo = make_shared<AsmAnalysisInfo>();
|
||||
AsmAnalyzer analyzer(*analysisInfo, errorReporter, _dialect, {}, parserResult->dataNames());
|
||||
// TODO this should be done recursively.
|
||||
if (!analyzer.analyze(*parserResult->code) || !errorReporter.errors().empty())
|
||||
if (!analyzer.analyze(*parserResult->code) || errorReporter.hasErrors())
|
||||
return {};
|
||||
return {std::move(parserResult->code), std::move(analysisInfo)};
|
||||
}
|
||||
|
||||
@@ -332,7 +332,7 @@ BOOST_FIXTURE_TEST_CASE(if_statement_custom_weights, CustomWeightFixture)
|
||||
BOOST_AUTO_TEST_CASE(switch_statement_tiny)
|
||||
{
|
||||
BOOST_CHECK_EQUAL(codeSize(
|
||||
"{ switch calldatasize() default {} }"
|
||||
"{ switch calldatasize() case 0 {} }"
|
||||
), 4);
|
||||
}
|
||||
|
||||
|
||||
@@ -362,7 +362,7 @@ bool YulOptimizerTest::parse(ostream& _stream, string const& _linePrefix, bool c
|
||||
ErrorList errors;
|
||||
soltestAssert(m_dialect, "");
|
||||
std::tie(m_ast, m_analysisInfo) = yul::test::parse(m_source, *m_dialect, errors);
|
||||
if (!m_ast || !m_analysisInfo || !errors.empty())
|
||||
if (!m_ast || !m_analysisInfo || !Error::containsOnlyWarnings(errors))
|
||||
{
|
||||
AnsiColorized(_stream, _formatted, {formatting::BOLD, formatting::RED}) << _linePrefix << "Error parsing source." << endl;
|
||||
printErrors(_stream, errors);
|
||||
|
||||
@@ -118,7 +118,7 @@ BOOST_AUTO_TEST_CASE(geneAddition_should_be_able_to_insert_before_first_position
|
||||
BOOST_TEST(mutatedChromosome.length() > chromosome.length());
|
||||
|
||||
vector<string> suffix(
|
||||
mutatedChromosome.optimisationSteps().end() - chromosome.length(),
|
||||
mutatedChromosome.optimisationSteps().end() - static_cast<ptrdiff_t>(chromosome.length()),
|
||||
mutatedChromosome.optimisationSteps().end()
|
||||
);
|
||||
BOOST_TEST(suffix == chromosome.optimisationSteps());
|
||||
@@ -135,7 +135,7 @@ BOOST_AUTO_TEST_CASE(geneAddition_should_be_able_to_insert_after_last_position)
|
||||
|
||||
vector<string> prefix(
|
||||
mutatedChromosome.optimisationSteps().begin(),
|
||||
mutatedChromosome.optimisationSteps().begin() + chromosome.length()
|
||||
mutatedChromosome.optimisationSteps().begin() + static_cast<ptrdiff_t>(chromosome.length())
|
||||
);
|
||||
BOOST_TEST(prefix == chromosome.optimisationSteps());
|
||||
}
|
||||
@@ -179,8 +179,8 @@ BOOST_AUTO_TEST_CASE(alternativeMutations_should_choose_between_mutations_with_g
|
||||
for (size_t i = 0; i < 10; ++i)
|
||||
{
|
||||
Chromosome mutatedChromosome = mutation(chromosome);
|
||||
cCount += static_cast<int>(mutatedChromosome == Chromosome("c"));
|
||||
fCount += static_cast<int>(mutatedChromosome == Chromosome("f"));
|
||||
cCount += (mutatedChromosome == Chromosome("c") ? 1 : 0);
|
||||
fCount += (mutatedChromosome == Chromosome("f") ? 1 : 0);
|
||||
}
|
||||
|
||||
// This particular seed results in 7 "c"s out of 10 which looks plausible given the 80% chance.
|
||||
|
||||
@@ -135,7 +135,7 @@ BOOST_FIXTURE_TEST_CASE(makeRandom_should_get_chromosome_lengths_from_specified_
|
||||
size_t maxLength = 5;
|
||||
assert(chromosomeCount % maxLength == 0);
|
||||
|
||||
auto nextLength = [counter = 0, maxLength]() mutable { return counter++ % maxLength; };
|
||||
auto nextLength = [counter = 0ul, maxLength]() mutable { return counter++ % maxLength; };
|
||||
auto population = Population::makeRandom(m_fitnessMetric, chromosomeCount, nextLength);
|
||||
|
||||
// We can't rely on the order since the population sorts its chromosomes immediately but
|
||||
|
||||
@@ -72,9 +72,13 @@ size_t phaser::test::countDifferences(Chromosome const& _chromosome1, Chromosome
|
||||
{
|
||||
size_t count = 0;
|
||||
for (size_t i = 0; i < min(_chromosome1.length(), _chromosome2.length()); ++i)
|
||||
count += static_cast<int>(_chromosome1.optimisationSteps()[i] != _chromosome2.optimisationSteps()[i]);
|
||||
if (_chromosome1.optimisationSteps()[i] != _chromosome2.optimisationSteps()[i])
|
||||
++count;
|
||||
|
||||
return count + abs(static_cast<int>(_chromosome1.length() - _chromosome2.length()));
|
||||
return count + static_cast<size_t>(abs(
|
||||
static_cast<long>(_chromosome1.length()) -
|
||||
static_cast<long>(_chromosome2.length())
|
||||
));
|
||||
}
|
||||
|
||||
TemporaryDirectory::TemporaryDirectory(std::string const& _prefix):
|
||||
|
||||
Reference in New Issue
Block a user