diff --git a/Changelog.md b/Changelog.md index 42d679caa3df..f84b6daf289f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,8 @@ ### 0.8.32 (unreleased) Language Features: +* Syntax Checker: Warn about identifiers selected for future promotion to Solidity keywords. +* Yul Analyzer: Warn about identifiers selected for future promotion to Yul keywords. Compiler Features: diff --git a/docs/assembly.rst b/docs/assembly.rst index 0458e3196f3e..30f451c4bd94 100644 --- a/docs/assembly.rst +++ b/docs/assembly.rst @@ -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` 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 diff --git a/docs/units-and-global-variables.rst b/docs/units-and-global-variables.rst index 4d8fed283f87..59623a1df7ea 100644 --- a/docs/units-and-global-variables.rst +++ b/docs/units-and-global-variables.rst @@ -430,3 +430,12 @@ These keywords are reserved in Solidity. They might become part of the syntax in ``mutable``, ``null``, ``of``, ``partial``, ``promise``, ``reference``, ``relocatable``, ``sealed``, ``sizeof``, ``static``, ``supports``, ``switch``, ``typedef``, ``typeof``, ``var``. + +.. note:: + The following identifiers will become unavailable in the future due to already being part of + the language syntax and thus selected to become Solidity keywords: + ``transient``, ``layout``, ``at``, ``error``, ``super``, ``this``. + + There are also Yul identifiers which are selected to become keywords in the future: + ``leave``, ``basefee``, ``prevrandao``, ``blobbasefee``, ``blobhash``, ``mcopy``, ``tstore``, ``tload``. + diff --git a/liblangutil/Token.cpp b/liblangutil/Token.cpp index 1c5ae6f4e707..a99272bef4b6 100644 --- a/liblangutil/Token.cpp +++ b/liblangutil/Token.cpp @@ -152,6 +152,40 @@ bool isYulKeyword(std::string_view const _literal) return _literal == "leave" || isYulKeyword(keywordByName(_literal)); } +bool isFutureSolidityKeyword(std::string const& _literal) +{ + std::set const futureSolidityKeywords = { + "transient", + "layout", + "at", + "error", + "super", + "this" + }; + return futureSolidityKeywords.contains(_literal); +} + +bool isFutureYulKeyword(std::string const& _literal) +{ + return _literal == "leave"; +} + +bool isFutureYulReservedIdentifier(std::string const& _literal) +{ + std::set futureReservedIdentifier = { + "basefee", + "blobbasefee", + "blobhash", + "clz", + "mcopy", + "memoryguard", + "prevrandao", + "tload", + "tstore", + }; + return futureReservedIdentifier.contains(_literal); +} + std::tuple fromIdentifierOrKeyword(std::string const& _literal) { // Used for `bytesM`, `uintM`, `intM`, `fixedMxN`, `ufixedMxN`. diff --git a/liblangutil/Token.h b/liblangutil/Token.h index bfbc89bb4839..0b5b6905a720 100644 --- a/liblangutil/Token.h +++ b/liblangutil/Token.h @@ -379,6 +379,12 @@ namespace TokenTraits bool isYulKeyword(std::string_view _literal); + bool isFutureSolidityKeyword(std::string const& _literal); + + bool isFutureYulKeyword(std::string const& _literal); + + bool isFutureYulReservedIdentifier(std::string const& _literal); + Token AssignmentToBinaryOp(Token op); // @returns the precedence > 0 for binary and compare diff --git a/libsolidity/analysis/NameAndTypeResolver.cpp b/libsolidity/analysis/NameAndTypeResolver.cpp index 2d55b46fc9f7..eb808c288f09 100644 --- a/libsolidity/analysis/NameAndTypeResolver.cpp +++ b/libsolidity/analysis/NameAndTypeResolver.cpp @@ -561,6 +561,20 @@ bool DeclarationRegistrationHelper::registerDeclaration( ); } + if ( + TokenTraits::isFutureSolidityKeyword(name) || + TokenTraits::isFutureYulKeyword(name) + ) + _errorReporter.warning( + 6335_error, + _declaration.location(), + fmt::format( + "\"{}\" will be promoted to keyword in the next breaking version" + " and will not be allowed as an identifier anymore.", + name + ) + ); + if (!_container.registerDeclaration(_declaration, _name, _errorLocation, !_declaration.isVisibleInContract() || _inactive, false)) { SourceLocation firstDeclarationLocation; diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp index 9bf784b36573..ef82b3b33e95 100644 --- a/libsolidity/analysis/SyntaxChecker.cpp +++ b/libsolidity/analysis/SyntaxChecker.cpp @@ -409,6 +409,7 @@ 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." ); + return true; } diff --git a/libyul/AsmAnalysis.cpp b/libyul/AsmAnalysis.cpp index 79d8bfd26860..27ff3d4285b6 100644 --- a/libyul/AsmAnalysis.cpp +++ b/libyul/AsmAnalysis.cpp @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -296,9 +297,7 @@ void AsmAnalyzer::operator()(VariableDeclaration const& _varDecl) m_currentScope->insideFunction() ); for (auto const& variable: _varDecl.variables) - { expectValidIdentifier(variable.name, nativeLocationOf(variable)); - } if (_varDecl.value) { @@ -745,6 +744,8 @@ void AsmAnalyzer::expectValidIdentifier(YulName _identifier, SourceLocation cons _location, fmt::format("The identifier \"{}\" is reserved and can not be used.", label) ); + + checkFutureReservedKeywordOrIdentifier(_identifier, _location); } bool AsmAnalyzer::validateInstructions(std::string_view _instructionIdentifier, langutil::SourceLocation const& _location) @@ -953,3 +954,21 @@ void AsmAnalyzer::validateObjectStructure(langutil::SourceLocation const& _astRo } } } + +void AsmAnalyzer::checkFutureReservedKeywordOrIdentifier(YulName _identifier, langutil::SourceLocation const& _location) +{ + if ( + TokenTraits::isFutureYulKeyword(_identifier.str()) || + TokenTraits::isFutureYulReservedIdentifier(_identifier.str()) + ) + m_errorReporter.warning( + 5470_error, + _location, + fmt::format( + "\"{}\" will be promoted to reserved Yul {} in the next breaking version " + "and will not be allowed anymore as an identifier.", + _identifier.str(), + (TokenTraits::isFutureYulKeyword(_identifier.str()) ? "keyword" : "identifier") + ) + ); +} diff --git a/libyul/AsmAnalysis.h b/libyul/AsmAnalysis.h index 51b8cde2ba1f..38e9f81e0a9a 100644 --- a/libyul/AsmAnalysis.h +++ b/libyul/AsmAnalysis.h @@ -128,6 +128,8 @@ class AsmAnalyzer void validateObjectStructure(langutil::SourceLocation const& _astRootLocation); + void checkFutureReservedKeywordOrIdentifier(YulName _identifier, langutil::SourceLocation const& _location); + yul::ExternalIdentifierAccess::Resolver m_resolver; Scope* m_currentScope = nullptr; /// Variables that are active at the current point in assembly (as opposed to diff --git a/test/cmdlineTests/memoryguard_shadowing_by_inline_assembly_identifiers/err b/test/cmdlineTests/memoryguard_shadowing_by_inline_assembly_identifiers/err new file mode 100644 index 000000000000..2c3d00161171 --- /dev/null +++ b/test/cmdlineTests/memoryguard_shadowing_by_inline_assembly_identifiers/err @@ -0,0 +1,23 @@ +Warning: "memoryguard" will be promoted to reserved Yul identifier in the next breaking version and will not be allowed anymore as an identifier. + --> input.sol:10:20: + | +10 | assembly { function memoryguard() {} } + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +Warning: "memoryguard" will be promoted to reserved Yul identifier in the next breaking version and will not be allowed anymore as an identifier. + --> input.sol:11:31: + | +11 | assembly { function f(memoryguard) {} } + | ^^^^^^^^^^^ + +Warning: "memoryguard" will be promoted to reserved Yul identifier in the next breaking version and will not be allowed anymore as an identifier. + --> input.sol:12:36: + | +12 | assembly { function f() -> memoryguard {} } + | ^^^^^^^^^^^ + +Warning: "memoryguard" will be promoted to reserved Yul identifier in the next breaking version and will not be allowed anymore as an identifier. + --> input.sol:13:24: + | +13 | assembly { let memoryguard } + | ^^^^^^^^^^^ diff --git a/test/externalTests/zeppelin.sh b/test/externalTests/zeppelin.sh index aca8311ac94c..c26038e0b971 100755 --- a/test/externalTests/zeppelin.sh +++ b/test/externalTests/zeppelin.sh @@ -116,7 +116,7 @@ function zeppelin_test const result = await runSuper(args); result.output.errors = (result.output.errors || []).filter(err => { - if (err.severity === "warning" && err.message.includes("deprecated")) { + if (err.severity === "warning" && (err.message.includes("deprecated") || err.message.includes("promoted"))) { return false; // suppress this warning } return true; diff --git a/test/libsolidity/syntaxTests/constants/constant_state_variable_named_transient.sol b/test/libsolidity/syntaxTests/constants/constant_state_variable_named_transient.sol index 4d9873d36d07..341af7301603 100644 --- a/test/libsolidity/syntaxTests/constants/constant_state_variable_named_transient.sol +++ b/test/libsolidity/syntaxTests/constants/constant_state_variable_named_transient.sol @@ -2,3 +2,4 @@ contract C { int constant public transient = 0; } // ---- +// Warning 6335: (17-50): "transient" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. diff --git a/test/libsolidity/syntaxTests/dataLocations/data_location_in_function_type_fail.sol b/test/libsolidity/syntaxTests/dataLocations/data_location_in_function_type_fail.sol index cd46b15b0716..340fc9c6b0b3 100644 --- a/test/libsolidity/syntaxTests/dataLocations/data_location_in_function_type_fail.sol +++ b/test/libsolidity/syntaxTests/dataLocations/data_location_in_function_type_fail.sol @@ -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 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. diff --git a/test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_transient.sol b/test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_transient.sol index 98fbb2d5ee66..a2988568ba2b 100644 --- a/test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_transient.sol +++ b/test/libsolidity/syntaxTests/dataLocations/externalFunction/function_argument_location_specifier_test_external_transient.sol @@ -2,4 +2,5 @@ contract test { function f(bytes transient) external; } // ---- +// Warning 6335: (31-46): "transient" will be promoted to 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. diff --git a/test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_transient.sol b/test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_transient.sol index 4a5b6f999d86..cfa6900cb472 100644 --- a/test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_transient.sol +++ b/test/libsolidity/syntaxTests/dataLocations/internalFunction/function_argument_location_specifier_test_internal_transient.sol @@ -2,4 +2,5 @@ contract test { function f(bytes transient) internal {} } // ---- +// Warning 6335: (31-46): "transient" will be promoted to 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. diff --git a/test/libsolidity/syntaxTests/dataLocations/libraries/library_function_with_data_location_transient.sol b/test/libsolidity/syntaxTests/dataLocations/libraries/library_function_with_data_location_transient.sol index 75253342c4e0..deb208084b82 100644 --- a/test/libsolidity/syntaxTests/dataLocations/libraries/library_function_with_data_location_transient.sol +++ b/test/libsolidity/syntaxTests/dataLocations/libraries/library_function_with_data_location_transient.sol @@ -9,6 +9,14 @@ library L { function i2() external pure returns (uint[] transient) { } } // ---- +// Warning 6335: (28-44): "transient" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. +// Warning 6335: (103-119): "transient" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. +// Warning 6335: (141-157): "transient" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. +// Warning 6335: (218-234): "transient" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. +// Warning 6335: (256-272): "transient" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. +// Warning 6335: (329-345): "transient" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. +// Warning 6335: (367-383): "transient" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. +// Warning 6335: (444-460): "transient" will be promoted to 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. diff --git a/test/libsolidity/syntaxTests/dataLocations/libraryExternalFunction/function_argument_location_specifier_test_external_transient.sol b/test/libsolidity/syntaxTests/dataLocations/libraryExternalFunction/function_argument_location_specifier_test_external_transient.sol index 1dcedf49adcf..8e70f9389d01 100644 --- a/test/libsolidity/syntaxTests/dataLocations/libraryExternalFunction/function_argument_location_specifier_test_external_transient.sol +++ b/test/libsolidity/syntaxTests/dataLocations/libraryExternalFunction/function_argument_location_specifier_test_external_transient.sol @@ -2,4 +2,5 @@ library test { function f(bytes transient) external {} } // ---- +// Warning 6335: (30-45): "transient" will be promoted to 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. diff --git a/test/libsolidity/syntaxTests/dataLocations/libraryInternalFunction/function_argument_location_specifier_test_internal_transient.sol b/test/libsolidity/syntaxTests/dataLocations/libraryInternalFunction/function_argument_location_specifier_test_internal_transient.sol index d66fa7fadd2d..e0b4ee154ae5 100644 --- a/test/libsolidity/syntaxTests/dataLocations/libraryInternalFunction/function_argument_location_specifier_test_internal_transient.sol +++ b/test/libsolidity/syntaxTests/dataLocations/libraryInternalFunction/function_argument_location_specifier_test_internal_transient.sol @@ -2,4 +2,5 @@ library test { function f(bytes transient) internal pure {} } // ---- +// Warning 6335: (30-45): "transient" will be promoted to 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. diff --git a/test/libsolidity/syntaxTests/dataLocations/privateFunction/private_function_parameters_location_transient.sol b/test/libsolidity/syntaxTests/dataLocations/privateFunction/private_function_parameters_location_transient.sol index 750aa4fee522..3e6527a80858 100644 --- a/test/libsolidity/syntaxTests/dataLocations/privateFunction/private_function_parameters_location_transient.sol +++ b/test/libsolidity/syntaxTests/dataLocations/privateFunction/private_function_parameters_location_transient.sol @@ -2,4 +2,5 @@ contract C { function f(uint[] transient) private pure {} } // ---- +// Warning 6335: (28-44): "transient" will be promoted to 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. diff --git a/test/libsolidity/syntaxTests/dataLocations/privateFunction/private_function_return_parameters_location_transient.sol b/test/libsolidity/syntaxTests/dataLocations/privateFunction/private_function_return_parameters_location_transient.sol index d1bf8762480f..705035a0754c 100644 --- a/test/libsolidity/syntaxTests/dataLocations/privateFunction/private_function_return_parameters_location_transient.sol +++ b/test/libsolidity/syntaxTests/dataLocations/privateFunction/private_function_return_parameters_location_transient.sol @@ -2,4 +2,5 @@ contract C { function f() private pure returns (uint[] transient) {} } // ---- +// Warning 6335: (52-68): "transient" will be promoted to 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. diff --git a/test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_transient.sol b/test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_transient.sol index ce4f42f469e4..5f1d64874659 100644 --- a/test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_transient.sol +++ b/test/libsolidity/syntaxTests/dataLocations/publicFunction/function_argument_location_specifier_test_public_transient.sol @@ -2,4 +2,5 @@ contract test { function f(bytes transient) public; } // ---- +// Warning 6335: (31-46): "transient" will be promoted to 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. diff --git a/test/libsolidity/syntaxTests/dataLocations/publicFunction/public_function_return_parameters_location_transient.sol b/test/libsolidity/syntaxTests/dataLocations/publicFunction/public_function_return_parameters_location_transient.sol index 862b7d236bfa..287e974affbb 100644 --- a/test/libsolidity/syntaxTests/dataLocations/publicFunction/public_function_return_parameters_location_transient.sol +++ b/test/libsolidity/syntaxTests/dataLocations/publicFunction/public_function_return_parameters_location_transient.sol @@ -2,4 +2,5 @@ contract C { function h() public pure returns(uint[] transient) {} } // ---- +// Warning 6335: (50-66): "transient" will be promoted to 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. diff --git a/test/libsolidity/syntaxTests/dataLocations/transient_function_type_parameter.sol b/test/libsolidity/syntaxTests/dataLocations/transient_function_type_parameter.sol index 04f20e85c050..413656c6b542 100644 --- a/test/libsolidity/syntaxTests/dataLocations/transient_function_type_parameter.sol +++ b/test/libsolidity/syntaxTests/dataLocations/transient_function_type_parameter.sol @@ -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 keyword in the next breaking version and will not be allowed as an identifier anymore. diff --git a/test/libsolidity/syntaxTests/duplicateFunctions/illegal_names_exception.sol b/test/libsolidity/syntaxTests/duplicateFunctions/illegal_names_exception.sol index e7541fe233d4..7ac7d5249b1f 100644 --- a/test/libsolidity/syntaxTests/duplicateFunctions/illegal_names_exception.sol +++ b/test/libsolidity/syntaxTests/duplicateFunctions/illegal_names_exception.sol @@ -8,5 +8,7 @@ contract C { } } // ---- +// Warning 6335: (61-88): "this" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. +// Warning 6335: (90-118): "super" will be promoted to 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. diff --git a/test/libsolidity/syntaxTests/duplicateFunctions/illegal_names_functions.sol b/test/libsolidity/syntaxTests/duplicateFunctions/illegal_names_functions.sol index e6c7134850f6..7c0b1f81b020 100644 --- a/test/libsolidity/syntaxTests/duplicateFunctions/illegal_names_functions.sol +++ b/test/libsolidity/syntaxTests/duplicateFunctions/illegal_names_functions.sol @@ -12,6 +12,8 @@ contract C { // ---- // DeclarationError 3726: (17-78): The name "_" is reserved. // DeclarationError 3726: (84-117): The name "super" is reserved. +// Warning 6335: (84-117): "super" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. // DeclarationError 3726: (123-155): The name "this" is reserved. +// Warning 6335: (123-155): "this" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. // Warning 2319: (84-117): This declaration shadows a builtin symbol. // Warning 2319: (123-155): This declaration shadows a builtin symbol. diff --git a/test/libsolidity/syntaxTests/enums/enum_name_future_keyword_warning.sol b/test/libsolidity/syntaxTests/enums/enum_name_future_keyword_warning.sol new file mode 100644 index 000000000000..4765acc8637f --- /dev/null +++ b/test/libsolidity/syntaxTests/enums/enum_name_future_keyword_warning.sol @@ -0,0 +1,6 @@ +enum error { layout, at } +/// ---- +// ---- +// Warning 6335: (0-25): "error" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. +// Warning 6335: (13-19): "layout" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. +// Warning 6335: (21-23): "at" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. diff --git a/test/libsolidity/syntaxTests/enums/illegal_names.sol b/test/libsolidity/syntaxTests/enums/illegal_names.sol index 399d91ed1252..ab747607fb1b 100644 --- a/test/libsolidity/syntaxTests/enums/illegal_names.sol +++ b/test/libsolidity/syntaxTests/enums/illegal_names.sol @@ -22,10 +22,14 @@ contract C { } // ---- // DeclarationError 3726: (0-19): The name "this" is reserved. +// Warning 6335: (0-19): "this" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. // DeclarationError 3726: (20-40): The name "super" is reserved. +// Warning 6335: (20-40): "super" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. // DeclarationError 3726: (41-57): The name "_" is reserved. // DeclarationError 3726: (72-76): The name "this" is reserved. +// Warning 6335: (72-76): "this" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. // DeclarationError 3726: (82-87): The name "super" is reserved. +// Warning 6335: (82-87): "super" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. // DeclarationError 3726: (93-94): The name "_" is reserved. // Warning 2319: (0-19): This declaration shadows a builtin symbol. // Warning 2319: (20-40): This declaration shadows a builtin symbol. diff --git a/test/libsolidity/syntaxTests/errors/struct_named_error.sol b/test/libsolidity/syntaxTests/errors/struct_named_error.sol index 0ee82ead66ae..9ef8e04f1f47 100644 --- a/test/libsolidity/syntaxTests/errors/struct_named_error.sol +++ b/test/libsolidity/syntaxTests/errors/struct_named_error.sol @@ -4,3 +4,4 @@ contract C { error x; } // ---- +// Warning 6335: (52-74): "error" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. diff --git a/test/libsolidity/syntaxTests/events/illegal_names_exception.sol b/test/libsolidity/syntaxTests/events/illegal_names_exception.sol index c45db8d7d123..99d91cc0109c 100644 --- a/test/libsolidity/syntaxTests/events/illegal_names_exception.sol +++ b/test/libsolidity/syntaxTests/events/illegal_names_exception.sol @@ -5,5 +5,7 @@ contract C { event _(); } // ---- +// Warning 6335: (80-93): "this" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. +// Warning 6335: (95-109): "super" will be promoted to 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. diff --git a/test/libsolidity/syntaxTests/events/illegal_names_exception_file_level.sol b/test/libsolidity/syntaxTests/events/illegal_names_exception_file_level.sol index 48b23dc38fb6..f59abd0ce275 100644 --- a/test/libsolidity/syntaxTests/events/illegal_names_exception_file_level.sol +++ b/test/libsolidity/syntaxTests/events/illegal_names_exception_file_level.sol @@ -2,3 +2,6 @@ event this(); event super(); event _(); +// ---- +// Warning 6335: (66-79): "this" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. +// Warning 6335: (80-94): "super" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. diff --git a/test/libsolidity/syntaxTests/freeFunctions/illegal_names.sol b/test/libsolidity/syntaxTests/freeFunctions/illegal_names.sol index aed22b225b61..d57d36584f7f 100644 --- a/test/libsolidity/syntaxTests/freeFunctions/illegal_names.sol +++ b/test/libsolidity/syntaxTests/freeFunctions/illegal_names.sol @@ -11,7 +11,9 @@ contract C { } // ---- // DeclarationError 3726: (0-18): The name "this" is reserved. +// Warning 6335: (0-18): "this" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. // DeclarationError 3726: (19-38): The name "super" is reserved. +// Warning 6335: (19-38): "super" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. // DeclarationError 3726: (39-54): The name "_" is reserved. // Warning 2319: (0-18): This declaration shadows a builtin symbol. // Warning 2319: (19-38): This declaration shadows a builtin symbol. diff --git a/test/libsolidity/syntaxTests/functionTypes/function_type_with_transient_param.sol b/test/libsolidity/syntaxTests/functionTypes/function_type_with_transient_param.sol index b38e37177ea1..ef3ec76aa0e7 100644 --- a/test/libsolidity/syntaxTests/functionTypes/function_type_with_transient_param.sol +++ b/test/libsolidity/syntaxTests/functionTypes/function_type_with_transient_param.sol @@ -5,4 +5,6 @@ contract C { // ---- // Warning 6162: (27-41): Naming function type parameters is deprecated. // Warning 6162: (69-85): Naming function type parameters is deprecated. +// Warning 6335: (27-41): "transient" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. +// Warning 6335: (69-85): "transient" will be promoted to 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. diff --git a/test/libsolidity/syntaxTests/immutable/illegal_names.sol b/test/libsolidity/syntaxTests/immutable/illegal_names.sol index a80083ed8ba5..a9c03fc8966d 100644 --- a/test/libsolidity/syntaxTests/immutable/illegal_names.sol +++ b/test/libsolidity/syntaxTests/immutable/illegal_names.sol @@ -5,7 +5,9 @@ contract C { } // ---- // DeclarationError 3726: (17-37): The name "super" is reserved. +// Warning 6335: (17-37): "super" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. // DeclarationError 3726: (43-59): The name "_" is reserved. // DeclarationError 3726: (65-84): The name "this" is reserved. +// Warning 6335: (65-84): "this" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. // Warning 2319: (17-37): This declaration shadows a builtin symbol. // Warning 2319: (65-84): This declaration shadows a builtin symbol. diff --git a/test/libsolidity/syntaxTests/immutable/immutable_state_var_named_transient.sol b/test/libsolidity/syntaxTests/immutable/immutable_state_var_named_transient.sol index c0ac3a8abb3c..ee043369968a 100644 --- a/test/libsolidity/syntaxTests/immutable/immutable_state_var_named_transient.sol +++ b/test/libsolidity/syntaxTests/immutable/immutable_state_var_named_transient.sol @@ -2,3 +2,4 @@ contract C { address public immutable transient; } // ---- +// Warning 6335: (17-51): "transient" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. diff --git a/test/libsolidity/syntaxTests/imports/import_alias_name_future_keyword_warning.sol b/test/libsolidity/syntaxTests/imports/import_alias_name_future_keyword_warning.sol new file mode 100644 index 000000000000..81b58b0f7ece --- /dev/null +++ b/test/libsolidity/syntaxTests/imports/import_alias_name_future_keyword_warning.sol @@ -0,0 +1,7 @@ +==== Source: a ==== +contract A {} +==== Source: b ==== +import {A as layout} from "a"; +contract C is layout {} +// ---- +// Warning 6335: (a:0-13): "layout" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. diff --git a/test/libsolidity/syntaxTests/imports/import_name_future_keyword_warning.sol b/test/libsolidity/syntaxTests/imports/import_name_future_keyword_warning.sol new file mode 100644 index 000000000000..3200d4a7aeff --- /dev/null +++ b/test/libsolidity/syntaxTests/imports/import_name_future_keyword_warning.sol @@ -0,0 +1,11 @@ +==== Source: a ==== +uint constant CONST = 10; +==== Source: b ==== +import "a" as super; +contract C { + uint x = super.CONST; +} +// ---- +// DeclarationError 3726: (b:0-20): The name "super" is reserved. +// Warning 6335: (b:0-20): "super" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. +// Warning 2319: (b:0-20): This declaration shadows a builtin symbol. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/blobhash_pre_cancun_not_reserved.sol b/test/libsolidity/syntaxTests/inlineAssembly/blobhash_pre_cancun_not_reserved.sol index 1ac24cc6497a..1255c2678299 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/blobhash_pre_cancun_not_reserved.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/blobhash_pre_cancun_not_reserved.sol @@ -17,3 +17,5 @@ contract C { // ==== // EVMVersion: <=shanghai // ---- +// Warning 5470: (98-106): "blobhash" will be promoted to reserved Yul identifier in the next breaking version and will not be allowed anymore as an identifier. +// Warning 5470: (237-303): "blobhash" will be promoted to reserved Yul identifier in the next breaking version and will not be allowed anymore as an identifier. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/clash_with_non_reserved_pure_yul_builtin.sol b/test/libsolidity/syntaxTests/inlineAssembly/clash_with_non_reserved_pure_yul_builtin.sol index 9b6ee266c3ed..374861cd4191 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/clash_with_non_reserved_pure_yul_builtin.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/clash_with_non_reserved_pure_yul_builtin.sol @@ -8,3 +8,8 @@ contract C { assembly { let memoryguard } } } +// ---- +// Warning 5470: (207-232): "memoryguard" will be promoted to reserved Yul identifier in the next breaking version and will not be allowed anymore as an identifier. +// Warning 5470: (265-276): "memoryguard" will be promoted to reserved Yul identifier in the next breaking version and will not be allowed anymore as an identifier. +// Warning 5470: (318-329): "memoryguard" will be promoted to reserved Yul identifier in the next breaking version and will not be allowed anymore as an identifier. +// Warning 5470: (358-369): "memoryguard" will be promoted to reserved Yul identifier in the next breaking version and will not be allowed anymore as an identifier. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/function_name_future_keyword_warning.sol b/test/libsolidity/syntaxTests/inlineAssembly/function_name_future_keyword_warning.sol new file mode 100644 index 000000000000..b5cebc387741 --- /dev/null +++ b/test/libsolidity/syntaxTests/inlineAssembly/function_name_future_keyword_warning.sol @@ -0,0 +1,9 @@ +contract C { + function f() pure public { + assembly { + function error (a, b , c ) -> y,x,z { + } + } + } +} +// ---- diff --git a/test/libsolidity/syntaxTests/inlineAssembly/prevrandao_allowed_function_pre_paris.sol b/test/libsolidity/syntaxTests/inlineAssembly/prevrandao_allowed_function_pre_paris.sol index d85e77a45ef0..afa91be97aef 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/prevrandao_allowed_function_pre_paris.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/prevrandao_allowed_function_pre_paris.sol @@ -18,3 +18,5 @@ contract C { // ==== // EVMVersion: =byzantium // ---- +// Warning 6335: (165-183): "error" will be promoted to 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. diff --git a/test/libsolidity/syntaxTests/userDefinedValueType/udvt_name_future_keyword_warning.sol b/test/libsolidity/syntaxTests/userDefinedValueType/udvt_name_future_keyword_warning.sol new file mode 100644 index 000000000000..491931ed0f55 --- /dev/null +++ b/test/libsolidity/syntaxTests/userDefinedValueType/udvt_name_future_keyword_warning.sol @@ -0,0 +1,3 @@ +type error is int; +// ---- +// Warning 6335: (0-18): "error" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. diff --git a/test/libsolidity/syntaxTests/variableDeclaration/illegal_names.sol b/test/libsolidity/syntaxTests/variableDeclaration/illegal_names.sol index 24d1d98d6e67..329ed8ba7a4e 100644 --- a/test/libsolidity/syntaxTests/variableDeclaration/illegal_names.sol +++ b/test/libsolidity/syntaxTests/variableDeclaration/illegal_names.sol @@ -13,14 +13,20 @@ contract D { } // ---- // DeclarationError 3726: (0-22): The name "this" is reserved. +// Warning 6335: (0-22): "this" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. // DeclarationError 3726: (24-47): The name "super" is reserved. +// Warning 6335: (24-47): "super" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. // DeclarationError 3726: (49-68): The name "_" is reserved. // DeclarationError 3726: (84-96): The name "this" is reserved. +// Warning 6335: (84-96): "this" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. // DeclarationError 3726: (99-108): The name "super" is reserved. +// Warning 6335: (99-108): "super" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. // DeclarationError 3726: (111-141): The name "_" is reserved. // DeclarationError 3726: (160-174): The name "this" is reserved. +// Warning 6335: (160-174): "this" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. // DeclarationError 3726: (177-201): The name "_" is reserved. // DeclarationError 3726: (188-198): The name "super" is reserved. +// Warning 6335: (188-198): "super" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. // Warning 2519: (84-96): This declaration shadows an existing declaration. // Warning 2519: (99-108): This declaration shadows an existing declaration. // Warning 2519: (111-141): This declaration shadows an existing declaration. diff --git a/test/libsolidity/syntaxTests/variableDeclaration/transient_as_identifier.sol b/test/libsolidity/syntaxTests/variableDeclaration/transient_as_identifier.sol index ced189faf061..3b7ee58a180d 100644 --- a/test/libsolidity/syntaxTests/variableDeclaration/transient_as_identifier.sol +++ b/test/libsolidity/syntaxTests/variableDeclaration/transient_as_identifier.sol @@ -23,3 +23,11 @@ contract D { } } // ---- +// Warning 6335: (17-53): "transient" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. +// Warning 6335: (75-89): "transient" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. +// Warning 6335: (101-115): "transient" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. +// Warning 6335: (127-149): "transient" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. +// Warning 6335: (168-181): "transient" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. +// Warning 6335: (253-267): "transient" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. +// Warning 6335: (321-334): "transient" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. +// Warning 6335: (368-385): "transient" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. diff --git a/test/libsolidity/syntaxTests/variableDeclaration/variable_named_leave.sol b/test/libsolidity/syntaxTests/variableDeclaration/variable_named_leave.sol new file mode 100644 index 000000000000..16172cdd1ce5 --- /dev/null +++ b/test/libsolidity/syntaxTests/variableDeclaration/variable_named_leave.sol @@ -0,0 +1,5 @@ +contract C { + uint leave = 1; +} +// ---- +// Warning 6335: (17-31): "leave" will be promoted to keyword in the next breaking version and will not be allowed as an identifier anymore. diff --git a/test/libyul/yulSyntaxTests/blobbasefee_identifier_pre_cancun.yul b/test/libyul/yulSyntaxTests/blobbasefee_identifier_pre_cancun.yul index 42c1f2c0a680..ca5b28db910e 100644 --- a/test/libyul/yulSyntaxTests/blobbasefee_identifier_pre_cancun.yul +++ b/test/libyul/yulSyntaxTests/blobbasefee_identifier_pre_cancun.yul @@ -4,3 +4,4 @@ // ==== // EVMVersion: <=shanghai // ---- +// Warning 5470: (6-31): "blobbasefee" will be promoted to reserved Yul identifier in the next breaking version and will not be allowed anymore as an identifier. diff --git a/test/libyul/yulSyntaxTests/blobhash_pre_cancun.yul b/test/libyul/yulSyntaxTests/blobhash_pre_cancun.yul index 777024cda0eb..6399faabe102 100644 --- a/test/libyul/yulSyntaxTests/blobhash_pre_cancun.yul +++ b/test/libyul/yulSyntaxTests/blobhash_pre_cancun.yul @@ -11,3 +11,5 @@ // ==== // EVMVersion: <=shanghai // ---- +// Warning 5470: (20-28): "blobhash" will be promoted to reserved Yul identifier in the next breaking version and will not be allowed anymore as an identifier. +// Warning 5470: (55-77): "blobhash" will be promoted to reserved Yul identifier in the next breaking version and will not be allowed anymore as an identifier. diff --git a/test/libyul/yulSyntaxTests/clz_pre_osaka.yul b/test/libyul/yulSyntaxTests/clz_pre_osaka.yul index 7380965981bb..85891797f310 100644 --- a/test/libyul/yulSyntaxTests/clz_pre_osaka.yul +++ b/test/libyul/yulSyntaxTests/clz_pre_osaka.yul @@ -12,3 +12,5 @@ // ==== // EVMVersion: