Skip to content

Commit 314c27b

Browse files
committed
Tests for Yul names clashing with builtins and reserved identifiers
1 parent d5d4558 commit 314c27b

10 files changed

+105
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
contract C {
2+
function f() public pure {
3+
// NOTE: memoryguard is a builtin but only in pure Yul, not inline assembly.
4+
// NOTE: memoryguard is not a reserved identifier.
5+
assembly { function memoryguard() {} }
6+
assembly { function f(memoryguard) {} }
7+
assembly { function f() -> memoryguard {} }
8+
assembly { let memoryguard }
9+
}
10+
}
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 {
3+
assembly {
4+
// NOTE: All EVM instruction names are reserved identifiers in Yul.
5+
// NOTE: We do provide builtins corresponding to these instructions.
6+
function add(mstore) -> sstore {}
7+
let coinbase
8+
}
9+
}
10+
}
11+
// ----
12+
// ParserError 5568: (245-248): Cannot use builtin function name "add" as identifier name.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
contract C {
2+
function f() public pure {
3+
assembly {
4+
// NOTE: All EVM instruction names are reserved identifiers in Yul.
5+
// NOTE: We don't provide builtins corresponding to these instructions.
6+
function dup1(dup2) -> dup3 {}
7+
let dup4
8+
}
9+
}
10+
}
11+
// ----
12+
// DeclarationError 5017: (239-269): The identifier "dup1" is reserved and can not be used.
13+
// DeclarationError 5017: (253-257): The identifier "dup2" is reserved and can not be used.
14+
// DeclarationError 5017: (262-266): The identifier "dup3" is reserved and can not be used.
15+
// DeclarationError 5017: (286-290): The identifier "dup4" is reserved and can not be used.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
contract C {
2+
function f() public view {
3+
assembly {
4+
// NOTE: These are builtins but only in pure Yul, not inline assembly.
5+
// NOTE: Names of these builtins are also reserved identifiers.
6+
function loadimmutable(setimmutable) -> datasize {}
7+
let dataoffset
8+
}
9+
}
10+
}
11+
// ----
12+
// DeclarationError 5017: (234-285): The identifier "loadimmutable" is reserved and can not be used.
13+
// DeclarationError 5017: (257-269): The identifier "setimmutable" is reserved and can not be used.
14+
// DeclarationError 5017: (274-282): The identifier "datasize" is reserved and can not be used.
15+
// DeclarationError 5017: (302-312): The identifier "dataoffset" is reserved and can not be used.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
let x: datacopy
3+
x := true: loadimmutable
4+
5+
function f(y: linkersymbol) {}
6+
}
7+
// ----
8+
// ParserError 5568: (13-21): Cannot use builtin function name "datacopy" as identifier name.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
{ function memoryguard() {} }
3+
{ function f(memoryguard) {} }
4+
{ function f() -> memoryguard {} }
5+
{ let memoryguard }
6+
}
7+
// ----
8+
// ParserError 5568: (17-28): Cannot use builtin function name "memoryguard" as identifier name.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
// NOTE: All EVM instruction names are reserved identifiers in Yul.
3+
// NOTE: We do provide builtins corresponding to these instructions.
4+
function add(mstore) -> sstore {}
5+
let coinbase
6+
}
7+
// ----
8+
// ParserError 5568: (160-163): Cannot use builtin function name "add" as identifier name.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
// NOTE: All EVM instruction names are reserved identifiers in Yul.
3+
// NOTE: We don't provide builtins corresponding to these instructions.
4+
function dup1(dup2) -> dup3 {}
5+
let dup4
6+
}
7+
// ----
8+
// DeclarationError 5017: (154-184): The identifier "dup1" is reserved and can not be used.
9+
// DeclarationError 5017: (168-172): The identifier "dup2" is reserved and can not be used.
10+
// DeclarationError 5017: (177-181): The identifier "dup3" is reserved and can not be used.
11+
// DeclarationError 5017: (193-197): The identifier "dup4" is reserved and can not be used.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
// NOTE: These are builtins but only in pure Yul, not inline assembly.
3+
// NOTE: Names of these builtins are also reserved identifiers.
4+
function loadimmutable(setimmutable) -> datasize {}
5+
let dataoffset
6+
}
7+
// ----
8+
// ParserError 5568: (158-171): Cannot use builtin function name "loadimmutable" as identifier name.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
let x: jump
3+
x := true: dup12
4+
5+
function f(y: jumpi) {}
6+
}
7+
// ----
8+
// ParserError 5473: (10-17): Types are not supported in untyped Yul.
9+
// ParserError 5473: (27-38): Types are not supported in untyped Yul.
10+
// ParserError 5473: (55-63): Types are not supported in untyped Yul.

0 commit comments

Comments
 (0)