Skip to content

Commit a6c2bce

Browse files
committed
Fix tests
1 parent 4ae9f97 commit a6c2bce

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

libsolidity/analysis/ReferencesResolver.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,15 @@ void ReferencesResolver::operator()(yul::VariableDeclaration const& _varDecl)
404404
SecondarySourceLocation ssl;
405405
for (auto const* decl: declarations)
406406
ssl.append("The shadowed declaration is here:", decl->location());
407-
if (!ssl.infos.empty())
407+
if (identifier.name.str() == "blobhash" && !m_evmVersion.hasBlobhash())
408+
m_errorReporter.warning(
409+
7527_error,
410+
nativeLocationOf(identifier),
411+
"\"blobhash\" was introduced as builtin function in EVM version Cancun "
412+
"but you are currently using EVM version " + m_evmVersion.name() +
413+
" and it will not behave as expected for EVM version >= Cancun."
414+
);
415+
else if (!ssl.infos.empty())
408416
m_errorReporter.declarationError(
409417
3859_error,
410418
nativeLocationOf(identifier),

test/libsolidity/semanticTests/builtinFunctions/blobhash.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ contract C {
99
return blobhash(2);
1010
}
1111
}
12+
// ====
13+
// EVMVersion: >=cancun
1214
// ----
1315
// f() -> 0x0100000000000000000000000000000000000000000000000000000000000001
1416
// g() -> 0x0100000000000000000000000000000000000000000000000000000000000002
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
contract C {
2+
function f() public pure returns (uint ret) {
3+
assembly {
4+
let blobhash := 1
5+
ret := blobhash
6+
}
7+
}
8+
function g() public pure returns (uint ret) {
9+
assembly {
10+
function blobhash() -> r {
11+
r := 1000
12+
}
13+
ret := blobhash()
14+
}
15+
}
16+
}
17+
// ====
18+
// EVMVersion: <=shanghai
19+
// ----
20+
// 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.

0 commit comments

Comments
 (0)