Skip to content

Commit a8418ce

Browse files
committed
Tests for basefee as identifier in inline assembly
Also added basefee to `EVMVersion::hasOpcode(...)`
1 parent 9ba46bf commit a8418ce

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
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-
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)