Merge type errors 8112 and 7617.

This commit is contained in:
wechman 2022-09-23 13:49:14 +02:00
parent d730e92dde
commit 6724455b16
2 changed files with 5 additions and 16 deletions

View File

@ -3992,6 +3992,9 @@ void TypeChecker::endVisit(UsingForDirective const& _usingFor)
*TypeProvider::withLocationIfReference(DataLocation::Storage, parameterTypes.at(0)) != *TypeProvider::withLocationIfReference(DataLocation::Storage, parameterTypes.at(0)) !=
*TypeProvider::withLocationIfReference(DataLocation::Storage, usingForType) *TypeProvider::withLocationIfReference(DataLocation::Storage, usingForType)
) )
) ||
(
parameterCount != 1 && parameterCount != 2
) )
) )
m_errorReporter.typeError( m_errorReporter.typeError(
@ -3999,21 +4002,7 @@ void TypeChecker::endVisit(UsingForDirective const& _usingFor)
path->location(), path->location(),
"The function \"" + joinHumanReadable(path->path(), ".") + "\" "+ "The function \"" + joinHumanReadable(path->path(), ".") + "\" "+
"needs to have one or two parameters of type " + "needs to have one or two parameters of type " +
_usingFor.typeName()->annotation().type->canonicalName() + usingForType->canonicalName() +
" and the same data location to be used for the operator " +
TokenTraits::friendlyName(*operator_) +
"."
);
else if (
parameterCount != 1 &&
parameterCount != 2
)
m_errorReporter.typeError(
8112_error,
path->location(),
"The function \"" + joinHumanReadable(path->path(), ".") + "\" "+
"needs to have one or two parameters of type " +
_usingFor.typeName()->annotation().type->canonicalName() +
" and the same data location to be used for the operator " + " and the same data location to be used for the operator " +
TokenTraits::friendlyName(*operator_) + TokenTraits::friendlyName(*operator_) +
"." "."

View File

@ -26,7 +26,7 @@ function f() pure {
// ---- // ----
// TypeError 1884: (33-36): The function "add" needs to have two parameters of type Int and the same data location to be used for the operator +. // TypeError 1884: (33-36): The function "add" needs to have two parameters of type Int and the same data location to be used for the operator +.
// TypeError 8112: (47-50): The function "sub" needs to have one or two parameters of type Int and the same data location to be used for the operator -. // TypeError 7617: (47-50): The function "sub" needs to have one or two parameters of type Int and the same data location to be used for the operator -.
// TypeError 7617: (61-64): The function "div" needs to have one or two parameters of type Int and the same data location to be used for the operator /. // TypeError 7617: (61-64): The function "div" needs to have one or two parameters of type Int and the same data location to be used for the operator /.
// TypeError 3605: (61-64): The function "div" needs to have parameters and return value of the same type to be used for the operator /. // TypeError 3605: (61-64): The function "div" needs to have parameters and return value of the same type to be used for the operator /.
// TypeError 2271: (325-350): Built-in binary operator + cannot be applied to types Int and Int. No matching user-defined operator found. // TypeError 2271: (325-350): Built-in binary operator + cannot be applied to types Int and Int. No matching user-defined operator found.