diff --git a/scripts/test_antlr_grammar.sh b/scripts/test_antlr_grammar.sh index b217518f8a09..ea00cc0f6e0e 100755 --- a/scripts/test_antlr_grammar.sh +++ b/scripts/test_antlr_grammar.sh @@ -128,7 +128,7 @@ done < <( grep -v -E 'inlineAssembly/prevrandao_disallowed_function_post_paris.sol' | # Skipping a test with "let blobhash := ..." grep -v -E 'inlineAssembly/blobhash_pre_cancun.sol' | - grep -v -E 'inlineAssembly/blobhash_pre_cancun_warning.sol' | + grep -v -E 'inlineAssembly/blobhash_pre_cancun_not_reserved.sol' | # Skipping license error, unrelated to the grammar grep -v -E 'license/license_double5.sol' | grep -v -E 'license/license_hidden_unicode.sol' | diff --git a/test/libsolidity/semanticTests/state/uncalled_blobhash.sol b/test/libsolidity/semanticTests/state/uncalled_blobhash.sol index 8ef6c68e48c5..df81a46918eb 100644 --- a/test/libsolidity/semanticTests/state/uncalled_blobhash.sol +++ b/test/libsolidity/semanticTests/state/uncalled_blobhash.sol @@ -1,5 +1,8 @@ contract C { function f() public returns (bytes32) { + // NOTE: The `tx_context.blob_hashes` is injected into EVMHost with the following hashes, indexed accordingly: + // 0 -> 0x0100000000000000000000000000000000000000000000000000000000000001 + // 1 -> 0x0100000000000000000000000000000000000000000000000000000000000002 return (blobhash)(0); } } diff --git a/test/libsolidity/syntaxTests/globalFunctions/blobhash_function_pre_cancun.sol b/test/libsolidity/syntaxTests/globalFunctions/blobhash_function_pre_cancun.sol new file mode 100644 index 000000000000..e5904f4e67bd --- /dev/null +++ b/test/libsolidity/syntaxTests/globalFunctions/blobhash_function_pre_cancun.sol @@ -0,0 +1,11 @@ +contract C { + function blobhash(uint256 index) public pure returns(bytes32) { + return bytes32(index); + } + function f() public pure returns(bytes32) { + return blobhash(2); + } +} +// ==== +// EVMVersion: <=shanghai +// ---- diff --git a/test/libsolidity/syntaxTests/globalFunctions/blobhash_function_shadow_warning.sol b/test/libsolidity/syntaxTests/globalFunctions/blobhash_function_shadow_warning.sol index 86f4f7af58c0..5469df9e6a03 100644 --- a/test/libsolidity/syntaxTests/globalFunctions/blobhash_function_shadow_warning.sol +++ b/test/libsolidity/syntaxTests/globalFunctions/blobhash_function_shadow_warning.sol @@ -6,5 +6,7 @@ contract C { return blobhash(2); } } +// ==== +// EVMVersion: >=cancun // ---- // Warning 2319: (17-117): This declaration shadows a builtin symbol. diff --git a/test/libsolidity/syntaxTests/globalFunctions/blobhash_no_call.sol b/test/libsolidity/syntaxTests/globalFunctions/blobhash_no_call.sol index 4e1e5626161e..369ea047806f 100644 --- a/test/libsolidity/syntaxTests/globalFunctions/blobhash_no_call.sol +++ b/test/libsolidity/syntaxTests/globalFunctions/blobhash_no_call.sol @@ -4,5 +4,7 @@ contract C blobhash; } } +// ==== +// EVMVersion: >=cancun // ---- // Warning 6133: (52-60): Statement has no effect. diff --git a/test/libsolidity/syntaxTests/globalFunctions/blobhash_not_declared_pre_cancun.sol b/test/libsolidity/syntaxTests/globalFunctions/blobhash_not_declared_pre_cancun.sol new file mode 100644 index 000000000000..a62f830150f4 --- /dev/null +++ b/test/libsolidity/syntaxTests/globalFunctions/blobhash_not_declared_pre_cancun.sol @@ -0,0 +1,10 @@ +contract C +{ + function f() public pure { + blobhash; + } +} +// ==== +// EVMVersion: <=shanghai +// ---- +// DeclarationError 7576: (52-60): Undeclared identifier. Did you mean "blockhash"? diff --git a/test/libsolidity/syntaxTests/globalFunctions/blobhash_var_pre_cancun.sol b/test/libsolidity/syntaxTests/globalFunctions/blobhash_var_pre_cancun.sol new file mode 100644 index 000000000000..42b54dc666a8 --- /dev/null +++ b/test/libsolidity/syntaxTests/globalFunctions/blobhash_var_pre_cancun.sol @@ -0,0 +1,9 @@ +contract C { + function f() public pure returns (bool) { + bool blobhash = true; + return blobhash; + } +} +// ==== +// EVMVersion: <=shanghai +// ---- diff --git a/test/libsolidity/syntaxTests/globalFunctions/blobhash_var_shadow_warning.sol b/test/libsolidity/syntaxTests/globalFunctions/blobhash_var_shadow_warning.sol index 4c46c6b6b661..f60378e8df31 100644 --- a/test/libsolidity/syntaxTests/globalFunctions/blobhash_var_shadow_warning.sol +++ b/test/libsolidity/syntaxTests/globalFunctions/blobhash_var_shadow_warning.sol @@ -5,5 +5,7 @@ contract C return blobhash; } } +// ==== +// EVMVersion: >=cancun // ---- // Warning 2319: (67-80): This declaration shadows a builtin symbol. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/blobhash_pre_cancun.sol b/test/libsolidity/syntaxTests/inlineAssembly/blobhash_pre_cancun_not_declared.sol similarity index 100% rename from test/libsolidity/syntaxTests/inlineAssembly/blobhash_pre_cancun.sol rename to test/libsolidity/syntaxTests/inlineAssembly/blobhash_pre_cancun_not_declared.sol diff --git a/test/libsolidity/syntaxTests/inlineAssembly/blobhash_pre_cancun_warning.sol b/test/libsolidity/syntaxTests/inlineAssembly/blobhash_pre_cancun_not_reserved.sol similarity index 65% rename from test/libsolidity/syntaxTests/inlineAssembly/blobhash_pre_cancun_warning.sol rename to test/libsolidity/syntaxTests/inlineAssembly/blobhash_pre_cancun_not_reserved.sol index 844f97b532e8..1ac24cc6497a 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/blobhash_pre_cancun_warning.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/blobhash_pre_cancun_not_reserved.sol @@ -17,4 +17,3 @@ contract C { // ==== // EVMVersion: <=shanghai // ---- -// Warning 7527: (98-106): "blobhash" was introduced as builtin function in EVM version Cancun but you are currently using EVM version shanghai and it will not behave as expected for EVM version >= Cancun.