mirror of
https://github.com/dlang/dmd.git
synced 2025-04-27 05:30:13 +03:00
Merge pull request #14255 from Geod24/useful-attributes-error
Print the inference error trace for regular inference errors Signed-off-by: Dennis <dkorpel@users.noreply.github.com> Signed-off-by: Nicholas Wilson <thewilsonator@users.noreply.github.com> Merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
This commit is contained in:
commit
b156f0a9fc
2 changed files with 23 additions and 20 deletions
|
@ -13133,26 +13133,26 @@ bool checkSharedAccess(Expression e, Scope* sc, bool returnRef = false)
|
|||
bool checkAddressVar(Scope* sc, Expression exp, VarDeclaration v)
|
||||
{
|
||||
//printf("checkAddressVar(exp: %s, v: %s)\n", exp.toChars(), v.toChars());
|
||||
if (v)
|
||||
if (v is null)
|
||||
return true;
|
||||
|
||||
if (!v.canTakeAddressOf())
|
||||
{
|
||||
if (!v.canTakeAddressOf())
|
||||
exp.error("cannot take address of `%s`", exp.toChars());
|
||||
return false;
|
||||
}
|
||||
if (sc.func && !sc.intypeof && !v.isDataseg())
|
||||
{
|
||||
const(char)* p = v.isParameter() ? "parameter" : "local";
|
||||
v.storage_class &= ~STC.maybescope;
|
||||
v.doNotInferScope = true;
|
||||
if (global.params.useDIP1000 != FeatureState.enabled &&
|
||||
!(v.storage_class & STC.temp) &&
|
||||
sc.setUnsafe())
|
||||
{
|
||||
exp.error("cannot take address of `%s`", exp.toChars());
|
||||
exp.error("cannot take address of %s `%s` in `@safe` function `%s`", p, v.toChars(), sc.func.toChars());
|
||||
return false;
|
||||
}
|
||||
if (sc.func && !sc.intypeof && !v.isDataseg())
|
||||
{
|
||||
const(char)* p = v.isParameter() ? "parameter" : "local";
|
||||
v.storage_class &= ~STC.maybescope;
|
||||
v.doNotInferScope = true;
|
||||
if (global.params.useDIP1000 != FeatureState.enabled &&
|
||||
!(v.storage_class & STC.temp) &&
|
||||
sc.setUnsafe())
|
||||
{
|
||||
exp.error("cannot take address of %s `%s` in `@safe` function `%s`", p, v.toChars(), sc.func.toChars());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -4466,12 +4466,15 @@ void errorSupplementalInferredSafety(FuncDeclaration fd, int maxDepth, bool depr
|
|||
errorFunc(s.loc, s.fmtStr,
|
||||
s.arg0 ? s.arg0.toChars() : "", s.arg1 ? s.arg1.toChars() : "", s.arg2 ? s.arg2.toChars() : "");
|
||||
}
|
||||
else if (FuncDeclaration fd2 = cast(FuncDeclaration) s.arg0)
|
||||
else if (s.arg0.dyncast() == DYNCAST.dsymbol)
|
||||
{
|
||||
if (maxDepth > 0)
|
||||
if (FuncDeclaration fd2 = (cast(Dsymbol) s.arg0).isFuncDeclaration())
|
||||
{
|
||||
errorFunc(s.loc, "which calls `%s`", fd2.toPrettyChars());
|
||||
errorSupplementalInferredSafety(fd2, maxDepth - 1, deprecation);
|
||||
if (maxDepth > 0)
|
||||
{
|
||||
errorFunc(s.loc, "which calls `%s`", fd2.toPrettyChars());
|
||||
errorSupplementalInferredSafety(fd2, maxDepth - 1, deprecation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue