Skip to content

Commit 892700d

Browse files
committed
Tests for basefee as identifier in inline assembly
Also added basefee to `EVMVersion::hasOpcode(...)`
1 parent 7f1a2be commit 892700d

File tree

4 files changed

+39
-2
lines changed

4 files changed

+39
-2
lines changed

liblangutil/EVMVersion.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ bool EVMVersion::hasOpcode(Instruction _opcode) const
4646
return hasChainID();
4747
case Instruction::SELFBALANCE:
4848
return hasSelfBalance();
49+
case Instruction::BASEFEE:
50+
return hasBaseFee();
4951
default:
5052
return true;
5153
}
5254
}
53-

scripts/test_antlr_grammar.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ done < <(
118118
grep -v -E 'literals/.*_direction_override.*.sol' |
119119
# Skipping a test with "revert E;" because ANTLR cannot distinguish it from
120120
# a variable declaration.
121-
grep -v -E 'revertStatement/non_called.sol'
121+
grep -v -E 'revertStatement/non_called.sol' |
122+
# Skipping a test with "let basefee := ..."
123+
grep -v -E 'inlineAssembly/basefee_berlin_function.sol'
122124
)
123125

124126
YUL_FILES=()
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
contract C {
2+
function f() public view returns (uint ret) {
3+
assembly {
4+
let basefee := sload(0)
5+
ret := basefee
6+
}
7+
}
8+
function g() public pure returns (uint ret) {
9+
assembly {
10+
function basefee() -> r {
11+
r := 1000
12+
}
13+
ret := basefee()
14+
}
15+
}
16+
}
17+
// ====
18+
// compileViaYul: also
19+
// EVMVersion: <=berlin
20+
// ----
21+
// f() -> 0
22+
// g() -> 1000
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
contract C {
2+
function f() public view returns (uint ret) {
3+
assembly {
4+
let basefee := sload(0)
5+
ret := basefee
6+
}
7+
}
8+
}
9+
// ====
10+
// EVMVersion: =london
11+
// ----
12+
// ParserError 5568: (98-105): Cannot use builtin function name "basefee" as identifier name.

0 commit comments

Comments
 (0)