Skip to content

Commit 21db4b1

Browse files
wechmanRuko97
authored andcommitted
TypeChecker: Minor simplifications for operators and using for
1 parent 18ef9de commit 21db4b1

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

libsolidity/analysis/TypeChecker.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,7 +1751,9 @@ bool TypeChecker::visit(UnaryOperation const& _operation)
17511751
else
17521752
_operation.annotation().type = result.get();
17531753
_operation.annotation().isConstant = false;
1754-
_operation.annotation().isPure = !modifying && *_operation.subExpression().annotation().isPure;
1754+
_operation.annotation().isPure =
1755+
!modifying &&
1756+
*_operation.subExpression().annotation().isPure;
17551757
_operation.annotation().isLValue = false;
17561758

17571759
return false;
@@ -3750,8 +3752,9 @@ void TypeChecker::endVisit(UsingForDirective const& _usingFor)
37503752
solAssert(m_errorReporter.hasErrors());
37513753
return;
37523754
}
3753-
solAssert(_usingFor.typeName()->annotation().type);
3754-
if (Declaration const* typeDefinition = _usingFor.typeName()->annotation().type->typeDefinition())
3755+
Type const* usingForType = _usingFor.typeName()->annotation().type;
3756+
solAssert(usingForType);
3757+
if (Declaration const* typeDefinition = usingForType->typeDefinition())
37553758
{
37563759
if (typeDefinition->scope() != m_currentSourceUnit)
37573760
m_errorReporter.typeError(
@@ -3785,10 +3788,12 @@ void TypeChecker::endVisit(UsingForDirective const& _usingFor)
37853788
return;
37863789
}
37873790

3788-
solAssert(_usingFor.typeName()->annotation().type);
3791+
Type const* usingForType = _usingFor.typeName()->annotation().type;
3792+
solAssert(usingForType);
3793+
37893794
Type const* normalizedType = TypeProvider::withLocationIfReference(
37903795
DataLocation::Storage,
3791-
_usingFor.typeName()->annotation().type
3796+
usingForType
37923797
);
37933798
solAssert(normalizedType);
37943799

@@ -3824,7 +3829,7 @@ void TypeChecker::endVisit(UsingForDirective const& _usingFor)
38243829
"The function \"{}\" cannot be bound to the type \"{}\" because the type cannot "
38253830
"be implicitly converted to the first argument of the function (\"{}\"){}",
38263831
joinHumanReadable(path->path(), "."),
3827-
_usingFor.typeName()->annotation().type->toString(true /* withoutDataLocation */),
3832+
usingForType->toString(true /* withoutDataLocation */),
38283833
functionType->selfType()->humanReadableName(),
38293834
result.message().empty() ? "." : ": " + result.message()
38303835
)

0 commit comments

Comments
 (0)