Move variables-in-interfaces checker to PostTypeChecker

refs #7566
This commit is contained in:
Mathias Baumann
2020-01-08 14:05:08 +01:00
committed by chriseth
parent 21844aa545
commit 2179562785
4 changed files with 64 additions and 16 deletions
-13
View File
@@ -317,10 +317,7 @@ bool TypeChecker::visit(StructDefinition const& _struct)
if (CycleDetector<StructDefinition>(visitor).run(_struct) != nullptr)
m_errorReporter.fatalTypeError(_struct.location(), "Recursive struct definition.");
bool insideStruct = true;
swap(insideStruct, m_insideStruct);
ASTNode::listAccept(_struct.members(), *this);
m_insideStruct = insideStruct;
return false;
}
@@ -451,16 +448,6 @@ bool TypeChecker::visit(FunctionDefinition const& _function)
bool TypeChecker::visit(VariableDeclaration const& _variable)
{
// Forbid any variable declarations inside interfaces unless they are part of
// * a function's input/output parameters,
// * or inside of a struct definition.
if (
m_scope->isInterface()
&& !_variable.isCallableOrCatchParameter()
&& !m_insideStruct
)
m_errorReporter.typeError(_variable.location(), "Variables cannot be declared in interfaces.");
if (_variable.typeName())
_variable.typeName()->accept(*this);