Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/assembly.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Solidity language without a compiler change.
pragma solidity >=0.4.16 <0.9.0;

library GetCode {
// This will report a warning - at you will be promoted to reserved keyword
function at(address addr) public view returns (bytes memory code) {
assembly {
// retrieve the size of the code, this needs assembly
Expand Down
31 changes: 31 additions & 0 deletions libsolidity/analysis/SyntaxChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,9 @@ bool SyntaxChecker::visit(ContractDefinition const& _contract)
"Functions are not allowed to have the same name as the contract. "
"If you intend this to be a constructor, use \"constructor(...) { ... }\" to define it."
);

checkFutureKeyword(_contract);

return true;
}

Expand Down Expand Up @@ -477,6 +480,8 @@ bool SyntaxChecker::visit(FunctionDefinition const& _function)
else if (!_function.isImplemented() && !_function.modifiers().empty())
m_errorReporter.syntaxError(2668_error, _function.location(), "Functions without implementation cannot have modifiers.");

checkFutureKeyword(_function);

return true;
}

Expand Down Expand Up @@ -508,5 +513,31 @@ bool SyntaxChecker::visitNode(ASTNode const& _node)
solAssert(m_sourceUnit);
solAssert(m_sourceUnit->experimentalSolidity());
}
auto const* declaration = dynamic_cast<Declaration const*>(&_node);
if (declaration)
checkFutureKeyword(*declaration);
return ASTConstVisitor::visitNode(_node);
}


void SyntaxChecker::checkFutureKeyword(Declaration const& _declaration)
{
std::set<ASTString> const futureKeywords = {
"transient",
"layout",
"at",
"error",
"super",
"this"
};
if (futureKeywords.count(_declaration.name()))
m_errorReporter.warning(
6335_error,
_declaration.location(),
fmt::format(
"\"{}\" will be promoted to reserved keyword in the next breaking version"
" and will not be allowed as an identifier anymore.",
_declaration.name()
)
);
}
4 changes: 4 additions & 0 deletions libsolidity/analysis/SyntaxChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ class SyntaxChecker: private ASTConstVisitor
/// without a block.
void checkSingleStatementVariableDeclaration(ASTNode const& _statement);

/// Reports a warning if the declaration name is scheduled to be
/// promoted to a keyword in the near future.
void checkFutureKeyword(Declaration const& _declaration);

bool visit(IfStatement const& _ifStatement) override;
bool visit(WhileStatement const& _whileStatement) override;
void endVisit(WhileStatement const& _whileStatement) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ contract C {
int constant public transient = 0;
}
// ----
// Warning 6335: (17-50): "transient" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ library L {

// ----
// Warning 6162: (251-267): Naming function type parameters is deprecated.
// Warning 6335: (251-267): "transient" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// TypeError 6651: (159-173): Data location must be "memory" or "calldata" for parameter in function, but "storage" was given.
// TypeError 6651: (251-267): Data location must be "memory" or "calldata" for parameter in function, but none was given.
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ contract test {
function f(bytes transient) external;
}
// ----
// Warning 6335: (31-46): "transient" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// TypeError 6651: (31-46): Data location must be "memory" or "calldata" for parameter in external function, but none was given.
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ contract test {
function f(bytes transient) internal {}
}
// ----
// Warning 6335: (31-46): "transient" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// TypeError 6651: (31-46): Data location must be "storage", "memory" or "calldata" for parameter in function, but none was given.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ library L {
function i2() external pure returns (uint[] transient) { }
}
// ----
// Warning 6335: (28-44): "transient" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (103-119): "transient" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (141-157): "transient" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (218-234): "transient" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (256-272): "transient" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (329-345): "transient" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (367-383): "transient" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (444-460): "transient" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// TypeError 6651: (28-44): Data location must be "storage", "memory" or "calldata" for parameter in function, but none was given.
// TypeError 6651: (103-119): Data location must be "storage", "memory" or "calldata" for return parameter in function, but none was given.
// TypeError 6651: (141-157): Data location must be "storage", "memory" or "calldata" for parameter in function, but none was given.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ library test {
function f(bytes transient) external {}
}
// ----
// Warning 6335: (30-45): "transient" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// TypeError 6651: (30-45): Data location must be "storage", "memory" or "calldata" for parameter in external function, but none was given.
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ library test {
function f(bytes transient) internal pure {}
}
// ----
// Warning 6335: (30-45): "transient" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// TypeError 6651: (30-45): Data location must be "storage", "memory" or "calldata" for parameter in function, but none was given.
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ contract C {
function f(uint[] transient) private pure {}
}
// ----
// Warning 6335: (28-44): "transient" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// TypeError 6651: (28-44): Data location must be "storage", "memory" or "calldata" for parameter in function, but none was given.
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ contract C {
function f() private pure returns (uint[] transient) {}
}
// ----
// Warning 6335: (52-68): "transient" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// TypeError 6651: (52-68): Data location must be "storage", "memory" or "calldata" for return parameter in function, but none was given.
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ contract test {
function f(bytes transient) public;
}
// ----
// Warning 6335: (31-46): "transient" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// TypeError 6651: (31-46): Data location must be "memory" or "calldata" for parameter in function, but none was given.
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ contract C {
function h() public pure returns(uint[] transient) {}
}
// ----
// Warning 6335: (50-66): "transient" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// TypeError 6651: (50-66): Data location must be "memory" or "calldata" for return parameter in function, but none was given.
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ contract C {
}
// ----
// Warning 6162: (27-41): Naming function type parameters is deprecated.
// Warning 6335: (27-41): "transient" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ contract C {
}
}
// ----
// Warning 6335: (61-88): "this" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (90-118): "super" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 2319: (61-88): This declaration shadows a builtin symbol.
// Warning 2319: (90-118): This declaration shadows a builtin symbol.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ contract C {
}
}
// ----
// Warning 6335: (84-117): "super" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (123-155): "this" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// DeclarationError 3726: (17-78): The name "_" is reserved.
// DeclarationError 3726: (84-117): The name "super" is reserved.
// DeclarationError 3726: (123-155): The name "this" is reserved.
Expand Down
4 changes: 4 additions & 0 deletions test/libsolidity/syntaxTests/enums/illegal_names.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ contract C {
E e;
}
// ----
// Warning 6335: (0-19): "this" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (20-40): "super" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (72-76): "this" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (82-87): "super" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// DeclarationError 3726: (0-19): The name "this" is reserved.
// DeclarationError 3726: (20-40): The name "super" is reserved.
// DeclarationError 3726: (41-57): The name "_" is reserved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ contract C {
event _();
}
// ----
// Warning 6335: (80-93): "this" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (95-109): "super" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 2319: (80-93): This declaration shadows a builtin symbol.
// Warning 2319: (95-109): This declaration shadows a builtin symbol.
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
event this();
event super();
event _();
// ----
// Warning 6335: (66-79): "this" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (80-94): "super" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
2 changes: 2 additions & 0 deletions test/libsolidity/syntaxTests/freeFunctions/illegal_names.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ contract C {
}
}
// ----
// Warning 6335: (0-18): "this" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (19-38): "super" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// DeclarationError 3726: (0-18): The name "this" is reserved.
// DeclarationError 3726: (19-38): The name "super" is reserved.
// DeclarationError 3726: (39-54): The name "_" is reserved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ contract C {
}
// ----
// Warning 6162: (27-41): Naming function type parameters is deprecated.
// Warning 6335: (27-41): "transient" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6162: (69-85): Naming function type parameters is deprecated.
// Warning 6335: (69-85): "transient" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// TypeError 6651: (69-85): Data location must be "memory" or "calldata" for parameter in function, but none was given.
2 changes: 2 additions & 0 deletions test/libsolidity/syntaxTests/immutable/illegal_names.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ contract C {
uint immutable this;
}
// ----
// Warning 6335: (17-37): "super" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (65-84): "this" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// DeclarationError 3726: (17-37): The name "super" is reserved.
// DeclarationError 3726: (43-59): The name "_" is reserved.
// DeclarationError 3726: (65-84): The name "this" is reserved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ contract C {
address public immutable transient;
}
// ----
// Warning 6335: (17-51): "transient" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ contract A {
modifier mod2(uint[] transient) { _; }
}
// ----
// Warning 6335: (31-47): "transient" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// TypeError 6651: (31-47): Data location must be "storage", "memory" or "calldata" for parameter in function, but none was given.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ contract C {
}
}
// ----
// Warning 6335: (28-38): "super" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (70-79): "this" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (167-177): "super" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (238-247): "this" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// DeclarationError 3726: (28-38): The name "super" is reserved.
// DeclarationError 3726: (70-79): The name "this" is reserved.
// DeclarationError 3726: (111-117): The name "_" is reserved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ contract C {
using _ for int;
}
// ----
// Warning 6335: (0-49): "super" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (51-99): "this" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// DeclarationError 3726: (0-49): The name "super" is reserved.
// DeclarationError 3726: (51-99): The name "this" is reserved.
// DeclarationError 3726: (100-145): The name "_" is reserved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ contract C {
}
}
// ----
// Warning 6335: (52-62): "super" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (76-85): "this" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// DeclarationError 3726: (52-62): The name "super" is reserved.
// DeclarationError 3726: (76-85): The name "this" is reserved.
// Warning 2319: (52-62): This declaration shadows a builtin symbol.
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
contract transient {}
// ----
// Warning 6335: (0-21): "transient" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
contract at layout at 0x1234ABC { }
// ----
// Warning 6335: (0-35): "at" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
contract layout layout at 0x1234ABC { }
// ----
// Warning 6335: (0-39): "layout" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ contract C layout at 0x1234 {
function at() public pure { }
}
// ----
// Warning 6335: (34-45): "layout" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (51-80): "at" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
contract at layout at uint40(bytes5(hex"0011223344")) { }
// ----
// Warning 6335: (0-57): "at" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// TypeError 6396: (22-53): The base slot of the storage layout must evaluate to a rational number.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
contract at layout at uint(42) { }
// ----
// Warning 6335: (0-34): "at" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// TypeError 6396: (22-30): The base slot of the storage layout must evaluate to a rational number.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
contract at layout at type(uint).max { }
// ----
// Warning 6335: (0-40): "at" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// TypeError 6396: (22-36): The base slot of the storage layout must evaluate to a rational number.
1 change: 1 addition & 0 deletions test/libsolidity/syntaxTests/unusedVariables/try_catch.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ contract test {
// ====
// EVMVersion: >=byzantium
// ----
// Warning 6335: (165-183): "error" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 5667: (49-55): Unused function parameter. Remove or comment out the variable name to silence this warning.
// Warning 5667: (89-95): Unused try/catch parameter. Remove or comment out the variable name to silence this warning.
// Warning 5667: (122-143): Unused try/catch parameter. Remove or comment out the variable name to silence this warning.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ contract D {
struct _ { uint super; }
}
// ----
// Warning 6335: (0-22): "this" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (24-47): "super" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (84-96): "this" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (99-108): "super" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (160-174): "this" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (188-198): "super" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// DeclarationError 3726: (0-22): The name "this" is reserved.
// DeclarationError 3726: (24-47): The name "super" is reserved.
// DeclarationError 3726: (49-68): The name "_" is reserved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,11 @@ contract D {
}
}
// ----
// Warning 6335: (17-53): "transient" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (75-89): "transient" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (101-115): "transient" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (127-149): "transient" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (168-181): "transient" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (253-267): "transient" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (321-334): "transient" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.
// Warning 6335: (368-385): "transient" will be promoted to reserved keyword in the next breaking version and will not be allowed as an identifier anymore.