Skip to content

Commit

Permalink
Tests for basefee as identifier in inline assembly
Browse files Browse the repository at this point in the history
Also added basefee to `EVMVersion::hasOpcode(...)`
  • Loading branch information
hrkrshnn committed Aug 11, 2021
1 parent 7f1a2be commit 892700d
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
3 changes: 2 additions & 1 deletion liblangutil/EVMVersion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ bool EVMVersion::hasOpcode(Instruction _opcode) const
return hasChainID();
case Instruction::SELFBALANCE:
return hasSelfBalance();
case Instruction::BASEFEE:
return hasBaseFee();
default:
return true;
}
}

4 changes: 3 additions & 1 deletion scripts/test_antlr_grammar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ done < <(
grep -v -E 'literals/.*_direction_override.*.sol' |
# Skipping a test with "revert E;" because ANTLR cannot distinguish it from
# a variable declaration.
grep -v -E 'revertStatement/non_called.sol'
grep -v -E 'revertStatement/non_called.sol' |
# Skipping a test with "let basefee := ..."
grep -v -E 'inlineAssembly/basefee_berlin_function.sol'
)

YUL_FILES=()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
contract C {
function f() public view returns (uint ret) {
assembly {
let basefee := sload(0)
ret := basefee
}
}
function g() public pure returns (uint ret) {
assembly {
function basefee() -> r {
r := 1000
}
ret := basefee()
}
}
}
// ====
// compileViaYul: also
// EVMVersion: <=berlin
// ----
// f() -> 0
// g() -> 1000
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
contract C {
function f() public view returns (uint ret) {
assembly {
let basefee := sload(0)
ret := basefee
}
}
}
// ====
// EVMVersion: =london
// ----
// ParserError 5568: (98-105): Cannot use builtin function name "basefee" as identifier name.

0 comments on commit 892700d

Please sign in to comment.