@@ -391,6 +391,9 @@ bool SyntaxChecker::visit(ContractDefinition const& _contract)
391391 " Functions are not allowed to have the same name as the contract. "
392392 " If you intend this to be a constructor, use \" constructor(...) { ... }\" to define it."
393393 );
394+
395+ checkFutureKeyword (_contract);
396+
394397 return true ;
395398}
396399
@@ -477,6 +480,8 @@ bool SyntaxChecker::visit(FunctionDefinition const& _function)
477480 else if (!_function.isImplemented () && !_function.modifiers ().empty ())
478481 m_errorReporter.syntaxError (2668_error, _function.location (), " Functions without implementation cannot have modifiers." );
479482
483+ checkFutureKeyword (_function);
484+
480485 return true ;
481486}
482487
@@ -508,5 +513,31 @@ bool SyntaxChecker::visitNode(ASTNode const& _node)
508513 solAssert (m_sourceUnit);
509514 solAssert (m_sourceUnit->experimentalSolidity ());
510515 }
516+ auto const * declaration = dynamic_cast <Declaration const *>(&_node);
517+ if (declaration)
518+ checkFutureKeyword (*declaration);
511519 return ASTConstVisitor::visitNode (_node);
512520}
521+
522+
523+ void SyntaxChecker::checkFutureKeyword (Declaration const & _declaration)
524+ {
525+ std::set<ASTString> const futureKeywords = {
526+ " transient" ,
527+ " layout" ,
528+ " at" ,
529+ " error" ,
530+ " super" ,
531+ " this"
532+ };
533+ if (futureKeywords.count (_declaration.name ()))
534+ m_errorReporter.warning (
535+ 6335_error,
536+ _declaration.location (),
537+ fmt::format (
538+ " \" {}\" will be promoted to reserved keyword in the next breaking version"
539+ " and will not be allowed as an identifier anymore." ,
540+ _declaration.name ()
541+ )
542+ );
543+ }
0 commit comments