@@ -50,7 +50,8 @@ bool DeclarationTypeChecker::visit(ElementaryTypeName const& _typeName)
50
50
_typeName.annotation ().type = TypeProvider::address ();
51
51
break ;
52
52
default :
53
- typeError (
53
+ m_errorReporter.typeError (
54
+ 2311_error,
54
55
_typeName.location (),
55
56
" Address types can only be payable or non-payable."
56
57
);
@@ -102,7 +103,7 @@ bool DeclarationTypeChecker::visit(StructDefinition const& _struct)
102
103
auto visitor = [&](StructDefinition const & _struct, auto & _cycleDetector, size_t _depth)
103
104
{
104
105
if (_depth >= 256 )
105
- fatalDeclarationError (_struct.location (), " Struct definition exhausts cyclic dependency validator." );
106
+ m_errorReporter. fatalDeclarationError (5651_error, _struct.location (), " Struct definition exhausts cyclic dependency validator." );
106
107
107
108
for (ASTPointer<VariableDeclaration> const & member: _struct.members ())
108
109
{
@@ -119,7 +120,7 @@ bool DeclarationTypeChecker::visit(StructDefinition const& _struct)
119
120
}
120
121
};
121
122
if (util::CycleDetector<StructDefinition>(visitor).run (_struct) != nullptr )
122
- fatalTypeError (_struct.location (), " Recursive struct definition." );
123
+ m_errorReporter. fatalTypeError (2046_error, _struct.location (), " Recursive struct definition." );
123
124
124
125
return false ;
125
126
}
@@ -145,7 +146,7 @@ void DeclarationTypeChecker::endVisit(UserDefinedTypeName const& _typeName)
145
146
else
146
147
{
147
148
_typeName.annotation ().type = TypeProvider::emptyTuple ();
148
- fatalTypeError (_typeName.location (), " Name has to refer to a struct, enum or contract." );
149
+ m_errorReporter. fatalTypeError (9755_error, _typeName.location (), " Name has to refer to a struct, enum or contract." );
149
150
}
150
151
}
151
152
bool DeclarationTypeChecker::visit (FunctionTypeName const & _typeName)
@@ -165,13 +166,13 @@ bool DeclarationTypeChecker::visit(FunctionTypeName const& _typeName)
165
166
case Visibility::External:
166
167
break ;
167
168
default :
168
- fatalTypeError (_typeName.location (), " Invalid visibility, can only be \" external\" or \" internal\" ." );
169
+ m_errorReporter. fatalTypeError (7653_error, _typeName.location (), " Invalid visibility, can only be \" external\" or \" internal\" ." );
169
170
return false ;
170
171
}
171
172
172
173
if (_typeName.isPayable () && _typeName.visibility () != Visibility::External)
173
174
{
174
- fatalTypeError (_typeName.location (), " Only external function types can be payable." );
175
+ m_errorReporter. fatalTypeError (6138_error, _typeName.location (), " Only external function types can be payable." );
175
176
return false ;
176
177
}
177
178
_typeName.annotation ().type = TypeProvider::function (_typeName);
@@ -226,7 +227,7 @@ void DeclarationTypeChecker::endVisit(ArrayTypeName const& _typeName)
226
227
return ;
227
228
}
228
229
if (baseType->storageBytes () == 0 )
229
- fatalTypeError (_typeName.baseType ().location (), " Illegal base type of storage size zero for array." );
230
+ m_errorReporter. fatalTypeError (9390_error, _typeName.baseType ().location (), " Illegal base type of storage size zero for array." );
230
231
if (Expression const * length = _typeName.length ())
231
232
{
232
233
TypePointer& lengthTypeGeneric = length->annotation ().type ;
@@ -235,13 +236,13 @@ void DeclarationTypeChecker::endVisit(ArrayTypeName const& _typeName)
235
236
RationalNumberType const * lengthType = dynamic_cast <RationalNumberType const *>(lengthTypeGeneric);
236
237
u256 lengthValue = 0 ;
237
238
if (!lengthType || !lengthType->mobileType ())
238
- typeError (length->location (), " Invalid array length, expected integer literal or constant expression." );
239
+ m_errorReporter. typeError (8922_error, length->location (), " Invalid array length, expected integer literal or constant expression." );
239
240
else if (lengthType->isZero ())
240
- typeError (length->location (), " Array with zero length specified." );
241
+ m_errorReporter. typeError (1220_error, length->location (), " Array with zero length specified." );
241
242
else if (lengthType->isFractional ())
242
- typeError (length->location (), " Array with fractional length specified." );
243
+ m_errorReporter. typeError (4323_error, length->location (), " Array with fractional length specified." );
243
244
else if (lengthType->isNegative ())
244
- typeError (length->location (), " Array with negative length specified." );
245
+ m_errorReporter. typeError (9308_error, length->location (), " Array with negative length specified." );
245
246
else
246
247
lengthValue = lengthType->literalValue (nullptr );
247
248
_typeName.annotation ().type = TypeProvider::array (DataLocation::Storage, baseType, lengthValue);
@@ -309,7 +310,7 @@ void DeclarationTypeChecker::endVisit(VariableDeclaration const& _variable)
309
310
errorString += " for variable" ;
310
311
}
311
312
errorString += " , but " + locationToString (varLoc) + " was given." ;
312
- typeError (_variable.location (), errorString);
313
+ m_errorReporter. typeError (6160_error, _variable.location (), errorString);
313
314
314
315
solAssert (!allowedDataLocations.empty (), " " );
315
316
varLoc = *allowedDataLocations.begin ();
@@ -359,24 +360,9 @@ void DeclarationTypeChecker::endVisit(VariableDeclaration const& _variable)
359
360
360
361
}
361
362
362
- void DeclarationTypeChecker::typeError (SourceLocation const & _location, string const & _description)
363
- {
364
- m_errorReporter.typeError (2311_error, _location, _description);
365
- }
366
-
367
- void DeclarationTypeChecker::fatalTypeError (SourceLocation const & _location, string const & _description)
368
- {
369
- m_errorReporter.fatalTypeError (5651_error, _location, _description);
370
- }
371
-
372
- void DeclarationTypeChecker::fatalDeclarationError (SourceLocation const & _location, string const & _description)
373
- {
374
- m_errorReporter.fatalDeclarationError (2046_error, _location, _description);
375
- }
376
-
377
363
bool DeclarationTypeChecker::check (ASTNode const & _node)
378
364
{
379
- unsigned errorCount = m_errorReporter.errorCount ();
365
+ auto watcher = m_errorReporter.errorWatcher ();
380
366
_node.accept (*this );
381
- return m_errorReporter. errorCount () == errorCount ;
367
+ return watcher. ok () ;
382
368
}
0 commit comments