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

eof: Syntax tests update #15661

Merged
merged 3 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion libevmasm/Assembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1660,7 +1660,14 @@ LinkerObject const& Assembly::assembleEOF() const

ptrdiff_t const relativeJumpOffset = static_cast<ptrdiff_t>(tagPos) - (static_cast<ptrdiff_t>(refPos) + 2);
// This cannot happen in practice because we'll run into section size limit first.
solAssert(-0x8000 <= relativeJumpOffset && relativeJumpOffset <= 0x7FFF, "Relative jump too far");
if (!(-0x8000 <= relativeJumpOffset && relativeJumpOffset <= 0x7FFF))
// TODO: Include source location. Note that origin locations we have in debug data are
// not usable for error reporting when compiling pure Yul because they point at the optimized source.
throw Error(
2703_error,
Error::Type::CodeGenerationError,
"Relative jump too far"
);
solAssert(relativeJumpOffset < -2 || 0 <= relativeJumpOffset, "Relative jump offset into immediate argument.");
setBigEndianUint16(ret.bytecode, refPos, static_cast<size_t>(static_cast<uint16_t>(relativeJumpOffset)));
}
Expand Down
4 changes: 3 additions & 1 deletion test/libsolidity/SyntaxTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ SyntaxTest::SyntaxTest(
{
static std::set<std::string> const compileViaYulAllowedValues{"true", "false"};

m_compileViaYul = m_reader.stringSetting("compileViaYul", "false");
auto const eofEnabled = solidity::test::CommonOptions::get().eofVersion().has_value();

m_compileViaYul = m_reader.stringSetting("compileViaYul", eofEnabled ? "true" : "false");
if (!util::contains(compileViaYulAllowedValues, m_compileViaYul))
BOOST_THROW_EXCEPTION(std::runtime_error("Invalid compileViaYul value: " + m_compileViaYul + "."));
m_optimiseYul = m_reader.boolSetting("optimize-yul", true);
Expand Down
13 changes: 13 additions & 0 deletions test/libsolidity/semanticTests/array/nested_calldata_storage.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
pragma abicoder v2;

contract C {
uint[][2] public tmp_i;
function i(uint[][2] calldata s) external { tmp_i = s; }
}
// ====
// compileViaYul: true
// ----
// i(uint256[][2]): 0x20, 0x40, 0xC0, 3, 0x0A01, 0x0A02, 0x0A03, 4, 0x0B01, 0x0B02, 0x0B03, 0x0B04
// gas irOptimized: 223100
// tmp_i(uint256,uint256): 0, 0 -> 0x0A01
// tmp_i(uint256,uint256): 1, 0 -> 0x0B01
13 changes: 13 additions & 0 deletions test/libsolidity/semanticTests/array/nested_calldata_storage2.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
pragma abicoder v2;

contract C {
uint[][] public tmp_i;
function i(uint[][] calldata s) external { tmp_i = s; }
}
// ====
// compileViaYul: true
// ----
// i(uint256[][]): 0x20, 2, 0x40, 0xC0, 3, 0x0A01, 0x0A02, 0x0A03, 4, 0x0B01, 0x0B02, 0x0B03, 0x0B04
// gas irOptimized: 245506
// tmp_i(uint256,uint256): 0, 0 -> 0x0A01
// tmp_i(uint256,uint256): 1, 0 -> 0x0B01
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ contract D {
return a + b;
}
}
// ====
// bytecodeFormat: legacy
// ----
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ contract Test {
L.set(item);
}
}
// ====
// bytecodeFormat: legacy
// ----
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ contract Test {
L.get(item);
}
}
// ====
// bytecodeFormat: legacy
// ----
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ contract C is B {
validate()
{}
}
// ====
// bytecodeFormat: legacy
// ----
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ import "B";
contract D is C {
constructor() validate B() validate C() validate {}
}
// ====
// bytecodeFormat: legacy
// ----
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ pragma abicoder v1;
import "A";

contract C is B {}
// ====
// bytecodeFormat: legacy
// ----
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ pragma abicoder v1;
import "A";

contract D is C {}
// ====
// bytecodeFormat: legacy
// ----
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ pragma abicoder v1;
import "A";

contract D is C {}
// ====
// bytecodeFormat: legacy
// ----
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ contract C is B {
_;
}
}
// ====
// bytecodeFormat: legacy
// ----
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,6 @@ struct Data {
contract X {
function get() public view returns (Data memory) {}
}
// ====
// bytecodeFormat: legacy
// ----
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ contract C {
function i(uint[][2] calldata s) external { tmp_i = s; }
}

// ====
// compileViaYul: false
// ----
// UnimplementedFeatureError 1834: (35-127): Copying nested calldata dynamic arrays to storage is not implemented in the old code generator.
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ contract C {
function i(uint[][] calldata s) external { tmp_i = s; }
}

// ====
// compileViaYul: false
// ----
// UnimplementedFeatureError 1834: (35-125): Copying nested calldata dynamic arrays to storage is not implemented in the old code generator.
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ library L2 {
contract A {
function f() public pure { type(L2).creationCode; }
}
// ====
// bytecodeFormat: legacy
// ----
// Warning 6133: (157-178): Statement has no effect.
4 changes: 3 additions & 1 deletion test/libsolidity/syntaxTests/constants/mod_div_rational.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ contract C {
fixed a3 = 0 / 0.123;
fixed a4 = 0 / -0.123;
}
// ====
// compileViaYul: true
// ----
// UnimplementedFeatureError 1834: (0-150): Not yet implemented - FixedPointType.
// UnimplementedFeatureError 1834: (28-53): Fixed point types not implemented.
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ pragma abicoder v1;
abstract contract C {
constructor(uint[][][] memory t) {}
}
// ====
// bytecodeFormat: legacy
// ----
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ contract C {
// ====
// EVMVersion: >=constantinople
// compileViaYul: true
// bytecodeFormat: legacy
// ----
// Warning 2264: (0-29): Experimental features are turned on. Do not use experimental features on live deployments.
// Info 4164: (31-61): Inferred type: void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ contract C
// ====
// EVMVersion: >=constantinople
// compileViaYul: true
// bytecodeFormat: legacy
// ----
// Warning 2264: (std.stub:63-92): Experimental features are turned on. Do not use experimental features on live deployments.
// Warning 2264: (0-29): Experimental features are turned on. Do not use experimental features on live deployments.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ contract C {
}
}
// ====
// bytecodeFormat: legacy
// ====
// EVMVersion: >=constantinople
// ----
// TypeError 9886: (78-101): Duplicate option "gas".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ contract C {
address(10).delegatecall{value: 7, gas: 3}("");
}
}
// ====
// bytecodeFormat: legacy
// ----
// TypeError 6189: (56-98): Cannot set option "value" for delegatecall.
// Warning 9302: (56-102): Return value of low-level calls not used.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ contract C {
}
// ====
// EVMVersion: >=byzantium
// bytecodeFormat: legacy
// ----
// TypeError 2842: (56-96): Cannot set option "value" for staticcall.
// Warning 9302: (56-100): Return value of low-level calls not used.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ contract C {
}
// ====
// EVMVersion: >=constantinople
// bytecodeFormat: legacy
// ----
// TypeError 1645: (78-110): Function call options have already been set, you have to combine them into a single {...}-option.
// TypeError 1645: (120-154): Function call options have already been set, you have to combine them into a single {...}-option.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
contract C {
function foo() pure internal {
address(10).delegatecall{value: 7, gas: 3}("");
}
}
// ====
// bytecodeFormat: >=EOFv1
// ----
// TypeError 6189: (56-98): Cannot set option "value" for delegatecall.
// TypeError 3765: (56-98): Function call option "gas" cannot be used when compiling to EOF.
// Warning 9302: (56-102): Return value of low-level calls not used.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
contract C {
function foo() pure internal {
address(10).staticcall{value: 7, gas: 3}("");
}
}
// ====
// EVMVersion: >=prague
// bytecodeFormat: >=EOFv1
// ----
// TypeError 2842: (56-96): Cannot set option "value" for staticcall.
// TypeError 3765: (56-96): Function call option "gas" cannot be used when compiling to EOF.
// Warning 9302: (56-100): Return value of low-level calls not used.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
contract C {
function foo() internal {
(bool success, ) = address(10).call{value: 7}("");
success;
}
}
// ====
// bytecodeFormat: >=EOFv1
// ----
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ contract C {
success;
}
}
// ====
// bytecodeFormat: legacy
// ----
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ contract C {
x{gas: 2}(1);
}
}

// ====
// bytecodeFormat: legacy
// ----
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
contract C {
function external_test_function() payable external {}
function comparison_operator_for_external_function_with_extra_slots() external returns (bool) {
return (
(this.external_test_function{value: 4} == this.external_test_function) &&
(this.external_test_function{value: 4} == this.external_test_function{value: 4})
);
}
}
// ----
// TypeError 2271: (201-269): Built-in binary operator == cannot be applied to types function () payable external and function () payable external.
// TypeError 2271: (287-365): Built-in binary operator == cannot be applied to types function () payable external and function () payable external.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
contract C {
function (uint) external returns (uint) x;
function f() public {
x{gas: 2}(1);
}
}
// ====
// bytecodeFormat: >=EOFv1
// ----
// TypeError 3765: (94-103): Function call option "gas" cannot be used when compiling to EOF.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
contract C {
function f (address) external returns (bool) {
this.f{gas: 42}.address;
function f (address) payable external returns (bool) {
this.f{value: 42}.address;
}
}
// ----
// Warning 6321: (56-60): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
// Warning 2018: (17-102): Function state mutability can be restricted to view
// Warning 6321: (64-68): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
2 changes: 2 additions & 0 deletions test/libsolidity/syntaxTests/immutable/creationCode.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ contract Test {
return type(A).creationCode;
}
}
// ====
// bytecodeFormat: legacy
// ----
4 changes: 3 additions & 1 deletion test/libsolidity/syntaxTests/immutable/no_assignments.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO: This test case should work the same way for EOF but EOF immutables support is not in its final state yet.
contract C {
uint immutable x;
constructor() {
Expand All @@ -8,6 +9,7 @@ contract C {
function f() external view returns(uint) { return x; }
}
// ====
// bytecodeFormat: legacy
// optimize-yul: true
// ----
// CodeGenerationError 1284: (0-168): Some immutables were read from but never assigned, possibly because of optimization.
// CodeGenerationError 1284: (115-283): Some immutables were read from but never assigned, possibly because of optimization.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ contract test {
fixed[3] memory a = [fixed(3.5), fixed(-4.25), fixed(967.125)];
}
}
// ====
// compileViaYul: true
// ----
// Warning 2072: (50-67): Unused local variable.
// Warning 2018: (20-119): Function state mutability can be restricted to pure
// UnimplementedFeatureError 1834: (0-121): Not yet implemented - FixedPointType.
// UnimplementedFeatureError 1834: (71-81): Fixed point types not implemented.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ contract test {
ufixed128x3[4] memory a = [ufixed128x3(3.5), 4.125, 2.5, 4.0];
}
}
// ====
// compileViaYul: true
// ----
// Warning 2072: (50-73): Unused local variable.
// Warning 2018: (20-118): Function state mutability can be restricted to pure
// UnimplementedFeatureError 1834: (0-120): Not yet implemented - FixedPointType.
// UnimplementedFeatureError 1834: (77-93): Fixed point types not implemented.
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ contract C {
}
}
}
// ====
// compileViaYul: false
// ----
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ contract c {
}
// ====
// EVMVersion: >=constantinople
// bytecodeFormat: legacy
// ----
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ contract C {
}
// ====
// EVMVersion: >=byzantium
// bytecodeFormat: legacy
// ----
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ contract C {
}
// ====
// EVMVersion: >=constantinople
// bytecodeFormat: legacy
// ----
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ contract c {
}
// ====
// EVMVersion: >=constantinople
// bytecodeFormat: legacy
// ----
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
contract C {
function f() public pure {
assembly {
switch codesize()
switch calldataload(0)
case hex"00" {}
case hex"1122" {}
}
}
}
// ----
Loading