Skip to content

Commit edb6783

Browse files
committed
Make name clash with a Yul builtin a non-fatal error
1 parent 314c27b commit edb6783

19 files changed

+34
-4
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Language Features:
66
Compiler Features:
77
* Error Reporting: Errors reported during code generation now point at the location of the contract when more fine-grained location is not available.
88
* SMTChecker: Z3 is now a runtime dependency, not a build dependency (except for emscripten build).
9+
* Yul Parser: Make name clash with a builtin a non-fatal error.
910

1011

1112
Bugfixes:

libyul/AsmParser.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,13 @@ YulName Parser::expectAsmIdentifier()
755755
{
756756
YulName name{currentLiteral()};
757757
if (currentToken() == Token::Identifier && m_dialect.findBuiltin(name.str()))
758-
fatalParserError(5568_error, "Cannot use builtin function name \"" + name.str() + "\" as identifier name.");
758+
// Non-fatal. We'll continue and wrongly parse it as an identifier. May lead to some spurious
759+
// errors after this point, but likely also much more useful ones.
760+
m_errorReporter.parserError(
761+
5568_error,
762+
currentLocation(),
763+
"Cannot use builtin function name \"" + name.str() + "\" as identifier name."
764+
);
759765
// NOTE: We keep the expectation here to ensure the correct source location for the error above.
760766
expectToken(Token::Identifier);
761767
return name;

test/libsolidity/syntaxTests/inlineAssembly/basefee_reserved_london.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ contract C {
1010
// EVMVersion: =london
1111
// ----
1212
// ParserError 5568: (98-105): Cannot use builtin function name "basefee" as identifier name.
13+
// ParserError 7104: (137-144): Builtin function "basefee" must be called.

test/libsolidity/syntaxTests/inlineAssembly/blobbasefee_reserved_cancun.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ contract C {
1010
// EVMVersion: >=cancun
1111
// ----
1212
// ParserError 5568: (98-109): Cannot use builtin function name "blobbasefee" as identifier name.
13+
// ParserError 7104: (141-152): Builtin function "blobbasefee" must be called.

test/libsolidity/syntaxTests/inlineAssembly/clash_with_reserved_builtin.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ contract C {
1010
}
1111
// ----
1212
// ParserError 5568: (245-248): Cannot use builtin function name "add" as identifier name.
13+
// ParserError 5568: (249-255): Cannot use builtin function name "mstore" as identifier name.
14+
// ParserError 5568: (260-266): Cannot use builtin function name "sstore" as identifier name.
15+
// ParserError 5568: (286-294): Cannot use builtin function name "coinbase" as identifier name.

test/libsolidity/syntaxTests/inlineAssembly/difficulty_disallowed_function_pre_paris.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ contract C {
1919
// EVMVersion: <paris
2020
// ----
2121
// ParserError 5568: (101-111): Cannot use builtin function name "difficulty" as identifier name.
22+
// ParserError 7104: (143-153): Builtin function "difficulty" must be called.

test/libsolidity/syntaxTests/inlineAssembly/mcopy_reserved_cancun.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ contract C {
1919
// EVMVersion: >=cancun
2020
// ----
2121
// ParserError 5568: (101-106): Cannot use builtin function name "mcopy" as identifier name.
22+
// ParserError 7104: (134-139): Builtin function "mcopy" must be called.

test/libsolidity/syntaxTests/inlineAssembly/prevrandao_disallowed_function_post_paris.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ contract C {
1919
// EVMVersion: >=paris
2020
// ----
2121
// ParserError 5568: (101-111): Cannot use builtin function name "prevrandao" as identifier name.
22+
// ParserError 7104: (143-153): Builtin function "prevrandao" must be called.

test/libsolidity/syntaxTests/inlineAssembly/tload_reserved_cancun.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ contract C {
1010
// EVMVersion: >=cancun
1111
// ----
1212
// ParserError 5568: (98-103): Cannot use builtin function name "tload" as identifier name.
13+
// ParserError 7104: (135-140): Builtin function "tload" must be called.

test/libsolidity/syntaxTests/inlineAssembly/tstore_reserved_cancun.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ contract C {
1010
// EVMVersion: >=cancun
1111
// ----
1212
// ParserError 5568: (98-104): Cannot use builtin function name "tstore" as identifier name.
13+
// ParserError 7104: (136-142): Builtin function "tstore" must be called.

0 commit comments

Comments
 (0)