40
40
#include < boost/algorithm/string/join.hpp>
41
41
#include < boost/algorithm/string/predicate.hpp>
42
42
43
+ #include < fmt/format.h>
44
+
43
45
#include < range/v3/algorithm/count_if.hpp>
44
46
#include < range/v3/view/drop_exactly.hpp>
45
47
#include < range/v3/view/enumerate.hpp>
@@ -1731,7 +1733,13 @@ bool TypeChecker::visit(UnaryOperation const& _operation)
1731
1733
TypeResult result = type (_operation.subExpression ())->unaryOperatorResult (op);
1732
1734
if (!result)
1733
1735
{
1734
- string description = " Built-in unary operator " + string (TokenTraits::toString (op)) + " cannot be applied to type " + subExprType->humanReadableName () + " ." + (!result.message ().empty () ? " " + result.message () : " " );
1736
+ string description = fmt::format (
1737
+ " Built-in unary operator {} cannot be applied to type {}.{}" ,
1738
+ TokenTraits::toString (op),
1739
+ subExprType->humanReadableName (),
1740
+ !result.message ().empty () ? " " + result.message () : " "
1741
+ );
1742
+
1735
1743
if (modifying)
1736
1744
// Cannot just report the error, ignore the unary operator, and continue,
1737
1745
// because the sub-expression was already processed with requireLValue()
@@ -3796,9 +3804,11 @@ void TypeChecker::endVisit(UsingForDirective const& _usingFor)
3796
3804
m_errorReporter.fatalTypeError (
3797
3805
4731_error,
3798
3806
path->location (),
3799
- " The function \" " + joinHumanReadable (path->path (), " ." ) + " \" " +
3800
- " does not have any parameters, and therefore cannot be bound to the type \" " +
3801
- (normalizedType ? normalizedType->toString (true /* withoutDataLocation */ ) : " *" ) + " \" ."
3807
+ fmt::format (
3808
+ " The function \" {}\" does not have any parameters, and therefore cannot be bound to the type \" {}\" ." ,
3809
+ joinHumanReadable (path->path (), " ." ),
3810
+ normalizedType ? normalizedType->toString (true /* withoutDataLocation */ ) : " *"
3811
+ )
3802
3812
);
3803
3813
3804
3814
FunctionType const * functionType = dynamic_cast <FunctionType const &>(*functionDefinition.type ()).asBoundFunction ();
@@ -3810,14 +3820,13 @@ void TypeChecker::endVisit(UsingForDirective const& _usingFor)
3810
3820
m_errorReporter.typeError (
3811
3821
3100_error,
3812
3822
path->location (),
3813
- " The function \" " + joinHumanReadable (path->path (), " ." ) + " \" " +
3814
- " cannot be bound to the type \" " + _usingFor.typeName ()->annotation ().type ->toString (true /* withoutDataLocation */ ) +
3815
- " \" because the type cannot be implicitly converted to the first argument" +
3816
- " of the function (\" " + functionType->selfType ()->humanReadableName () + " \" )" +
3817
- (
3818
- result.message ().empty () ?
3819
- " ." :
3820
- " : " + result.message ()
3823
+ fmt::format (
3824
+ " The function \" {}\" cannot be bound to the type \" {}\" because the type cannot "
3825
+ " be implicitly converted to the first argument of the function (\" {}\" ){}" ,
3826
+ joinHumanReadable (path->path (), " ." ),
3827
+ _usingFor.typeName ()->annotation ().type ->toString (true /* withoutDataLocation */ ),
3828
+ functionType->selfType ()->humanReadableName (),
3829
+ result.message ().empty () ? " ." : " : " + result.message ()
3821
3830
)
3822
3831
);
3823
3832
}
0 commit comments