Skip to content

Commit

Permalink
use ErrorSink on preFunctionParameters()
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Nov 2, 2024
1 parent f713bd3 commit 4cb72cc
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions compiler/src/dmd/expressionsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -2850,12 +2850,12 @@ private Expression rewriteOpAssign(BinExp exp)
* Params:
* sc = scope
* argumentList = arguments to function
* reportErrors = whether or not to report errors here. Some callers are not
* eSink = if not null, used to report errors. Some callers are not
* checking actual function params, so they'll do their own error reporting
* Returns:
* `true` when a semantic error occurred
*/
private bool preFunctionParameters(Scope* sc, ArgumentList argumentList, const bool reportErrors = true)
private bool preFunctionParameters(Scope* sc, ArgumentList argumentList, ErrorSink eSink)
{
Expressions* exps = argumentList.arguments;
if (!exps)
Expand All @@ -2876,19 +2876,19 @@ private bool preFunctionParameters(Scope* sc, ArgumentList argumentList, const b

if (arg.op == EXP.type)
{
if (reportErrors)
if (eSink)
{
error(arg.loc, "cannot pass type `%s` as a function argument", arg.toChars());
eSink.error(arg.loc, "cannot pass type `%s` as a function argument", arg.toChars());
arg = ErrorExp.get();
}
err = true;
}
}
else if (arg.type.toBasetype().ty == Tfunction)
{
if (reportErrors)
if (eSink)
{
error(arg.loc, "cannot pass function `%s` as a function argument", arg.toChars());
eSink.error(arg.loc, "cannot pass function `%s` as a function argument", arg.toChars());
arg = ErrorExp.get();
}
err = true;
Expand Down Expand Up @@ -4974,7 +4974,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
{
return setError();
}
if (preFunctionParameters(sc, exp.argumentList))
if (preFunctionParameters(sc, exp.argumentList, global.errorSink))
{
return setError();
}
Expand Down Expand Up @@ -5925,7 +5925,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
if (FuncExp fe = exp.e1.isFuncExp())
{
if (arrayExpressionSemantic(exp.arguments.peekSlice(), sc) ||
preFunctionParameters(sc, exp.argumentList))
preFunctionParameters(sc, exp.argumentList, global.errorSink))
return setError();

// Run e1 semantic even if arguments have any errors
Expand Down Expand Up @@ -6165,7 +6165,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
return;
}
if (arrayExpressionSemantic(exp.arguments.peekSlice(), sc) ||
preFunctionParameters(sc, exp.argumentList))
preFunctionParameters(sc, exp.argumentList, global.errorSink))
return setError();

// Check for call operator overload
Expand Down

0 comments on commit 4cb72cc

Please sign in to comment.