Skip to content

Commit 2722f7f

Browse files
fixup! Add and update tests
1 parent 48d116c commit 2722f7f

File tree

16 files changed

+43
-43
lines changed

16 files changed

+43
-43
lines changed

libsolidity/analysis/NameAndTypeResolver.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,17 @@ bool DeclarationRegistrationHelper::registerDeclaration(
561561
);
562562
}
563563

564+
if (TokenTraits::isFutureSolidityKeyword(_declaration.name()))
565+
_errorReporter.warning(
566+
6335_error,
567+
_declaration.location(),
568+
fmt::format(
569+
"\"{}\" will be promoted to keyword in the next breaking version"
570+
" and will not be allowed as an identifier anymore.",
571+
_declaration.name()
572+
)
573+
);
574+
564575
if (!_container.registerDeclaration(_declaration, _name, _errorLocation, !_declaration.isVisibleInContract() || _inactive, false))
565576
{
566577
SourceLocation firstDeclarationLocation;

libsolidity/analysis/SyntaxChecker.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -530,17 +530,3 @@ bool SyntaxChecker::visitNode(ASTNode const& _node)
530530
return ASTConstVisitor::visitNode(_node);
531531
}
532532

533-
534-
void SyntaxChecker::checkFutureKeyword(Declaration const& _declaration)
535-
{
536-
if (TokenTraits::isFutureSolidityKeyword(_declaration.name()))
537-
m_errorReporter.warning(
538-
6335_error,
539-
_declaration.location(),
540-
fmt::format(
541-
"\"{}\" will be promoted to keyword in the next breaking version"
542-
" and will not be allowed as an identifier anymore.",
543-
_declaration.name()
544-
)
545-
);
546-
}

libsolidity/analysis/SyntaxChecker.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@ class SyntaxChecker: private ASTConstVisitor
6666
/// without a block.
6767
void checkSingleStatementVariableDeclaration(ASTNode const& _statement);
6868

69-
/// Reports a warning if the declaration name is scheduled to be
70-
/// promoted to a keyword in the near future.
71-
void checkFutureKeyword(Declaration const& _declaration);
72-
7369
bool visit(IfStatement const& _ifStatement) override;
7470
bool visit(WhileStatement const& _whileStatement) override;
7571
void endVisit(WhileStatement const& _whileStatement) override;

test/libsolidity/syntaxTests/duplicateFunctions/illegal_names_functions.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ contract C {
1010
}
1111
}
1212
// ----
13-
// Warning 6335: (84-117): "super" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore.
14-
// Warning 6335: (123-155): "this" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore.
1513
// DeclarationError 3726: (17-78): The name "_" is reserved.
1614
// DeclarationError 3726: (84-117): The name "super" is reserved.
15+
// Warning 6335: (84-117): "super" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore.
1716
// DeclarationError 3726: (123-155): The name "this" is reserved.
17+
// Warning 6335: (123-155): "this" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore.
1818
// Warning 2319: (84-117): This declaration shadows a builtin symbol.
1919
// Warning 2319: (123-155): This declaration shadows a builtin symbol.

test/libsolidity/syntaxTests/enums/illegal_names.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ contract C {
2121
E e;
2222
}
2323
// ----
24-
// Warning 6335: (0-19): "this" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore.
25-
// Warning 6335: (20-40): "super" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore.
26-
// Warning 6335: (72-76): "this" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore.
27-
// Warning 6335: (82-87): "super" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore.
2824
// DeclarationError 3726: (0-19): The name "this" is reserved.
25+
// Warning 6335: (0-19): "this" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore.
2926
// DeclarationError 3726: (20-40): The name "super" is reserved.
27+
// Warning 6335: (20-40): "super" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore.
3028
// DeclarationError 3726: (41-57): The name "_" is reserved.
3129
// DeclarationError 3726: (72-76): The name "this" is reserved.
30+
// Warning 6335: (72-76): "this" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore.
3231
// DeclarationError 3726: (82-87): The name "super" is reserved.
32+
// Warning 6335: (82-87): "super" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore.
3333
// DeclarationError 3726: (93-94): The name "_" is reserved.
3434
// Warning 2319: (0-19): This declaration shadows a builtin symbol.
3535
// Warning 2319: (20-40): This declaration shadows a builtin symbol.

test/libsolidity/syntaxTests/errors/struct_named_error.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ contract C {
44
error x;
55
}
66
// ----
7+
// Warning 6335: (52-74): "error" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore.

test/libsolidity/syntaxTests/freeFunctions/illegal_names.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ contract C {
1010
}
1111
}
1212
// ----
13-
// Warning 6335: (0-18): "this" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore.
14-
// Warning 6335: (19-38): "super" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore.
1513
// DeclarationError 3726: (0-18): The name "this" is reserved.
14+
// Warning 6335: (0-18): "this" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore.
1615
// DeclarationError 3726: (19-38): The name "super" is reserved.
16+
// Warning 6335: (19-38): "super" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore.
1717
// DeclarationError 3726: (39-54): The name "_" is reserved.
1818
// Warning 2319: (0-18): This declaration shadows a builtin symbol.
1919
// Warning 2319: (19-38): This declaration shadows a builtin symbol.

test/libsolidity/syntaxTests/functionTypes/function_type_with_transient_param.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ contract C {
44
}
55
// ----
66
// Warning 6162: (27-41): Naming function type parameters is deprecated.
7-
// Warning 6335: (27-41): "transient" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore.
87
// Warning 6162: (69-85): Naming function type parameters is deprecated.
8+
// Warning 6335: (27-41): "transient" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore.
99
// Warning 6335: (69-85): "transient" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore.
1010
// TypeError 6651: (69-85): Data location must be "memory" or "calldata" for parameter in function, but none was given.

test/libsolidity/syntaxTests/immutable/illegal_names.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ contract C {
44
uint immutable this;
55
}
66
// ----
7-
// Warning 6335: (17-37): "super" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore.
8-
// Warning 6335: (65-84): "this" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore.
97
// DeclarationError 3726: (17-37): The name "super" is reserved.
8+
// Warning 6335: (17-37): "super" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore.
109
// DeclarationError 3726: (43-59): The name "_" is reserved.
1110
// DeclarationError 3726: (65-84): The name "this" is reserved.
11+
// Warning 6335: (65-84): "this" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore.
1212
// Warning 2319: (17-37): This declaration shadows a builtin symbol.
1313
// Warning 2319: (65-84): This declaration shadows a builtin symbol.

test/libsolidity/syntaxTests/modifiers/illegal_name.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ contract C {
55
}
66
// ----
77
// DeclarationError 3726: (14-34): The name "this" is reserved.
8+
// Warning 6335: (14-34): "this" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore.
89
// DeclarationError 3726: (36-57): The name "super" is reserved.
10+
// Warning 6335: (36-57): "super" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore.
911
// DeclarationError 3726: (59-76): The name "_" is reserved.
1012
// Warning 2319: (14-34): This declaration shadows a builtin symbol.
1113
// Warning 2319: (36-57): This declaration shadows a builtin symbol.

0 commit comments

Comments
 (0)