diff options
| author | Jay Kwak <82421531+jkwak-work@users.noreply.github.com> | 2025-05-15 01:55:17 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-15 01:55:17 +0000 |
| commit | 2275e18fc052239fe67f3fda68252ad92bb83ca9 (patch) | |
| tree | 19cdf1917811e1c40362ef468c5d3d6a20344517 /source/slang/slang-check-decl.cpp | |
| parent | 8c98714df2198db1aff4ce6c6f7922850e400f80 (diff) | |
Do not print errors in _coerce when "JustTrying". (#7064)
* Do not print errors in _coerce when "JustTrying".
While figuring out which generic-overload works best, `_coerce()` is
printing errors and Slang compilation terminates prematurely.
When `TryCheckGenericOverloadCandidateTypes()` is calling `_coerce()` in
"JustTrying" mode, the error messages should be snoozed.
The following logic shows the intention of how to silence the error
messages, but the chain of `sink` was broken in the middle and
`_coerce()` was using `getSink()` from the SemanticVisitor.
val = ExtractGenericArgInteger(
arg,
getType(m_astBuilder, valParamRef),
context.mode == OverloadResolveContext::Mode::JustTrying ? nullptr : getSink());
* Use tempSink when available.
Diffstat (limited to 'source/slang/slang-check-decl.cpp')
| -rw-r--r-- | source/slang/slang-check-decl.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp index c2c0c2cb6..bdd59c2c5 100644 --- a/source/slang/slang-check-decl.cpp +++ b/source/slang/slang-check-decl.cpp @@ -1868,7 +1868,8 @@ void SemanticsDeclHeaderVisitor::checkVarDeclCommon(VarDeclBase* varDecl) if (auto initExpr = varDecl->initExpr) { initExpr = CheckTerm(initExpr); - initExpr = coerce(CoercionSite::Initializer, varDecl->type.Ptr(), initExpr); + initExpr = + coerce(CoercionSite::Initializer, varDecl->type.Ptr(), initExpr, getSink()); varDecl->initExpr = initExpr; maybeInferArraySizeForVariable(varDecl); @@ -2348,7 +2349,7 @@ void SemanticsDeclBodyVisitor::checkVarDeclCommon(VarDeclBase* varDecl) if (initExpr->type.isWriteOnly) getSink()->diagnose(initExpr, Diagnostics::readingFromWriteOnly); - initExpr = coerce(CoercionSite::Initializer, varDecl->type.Ptr(), initExpr); + initExpr = coerce(CoercionSite::Initializer, varDecl->type.Ptr(), initExpr, getSink()); varDecl->initExpr = initExpr; // We need to ensure that any variable doesn't introduce @@ -4948,7 +4949,7 @@ bool SemanticsVisitor::trySynthesizeMethodRequirementWitness( // so we also need to coerce the result of the call to // the expected type. // - auto coercedCall = subVisitor.coerce(CoercionSite::Return, resultType, checkedCall); + auto coercedCall = subVisitor.coerce(CoercionSite::Return, resultType, checkedCall, getSink()); // If our overload resolution or type coercion failed, // then we have not been able to synthesize a witness @@ -5803,7 +5804,7 @@ bool SemanticsVisitor::synthesizeAccessorRequirements( // the expected type of the property. // auto coercedMemberRef = - subVisitor.coerce(CoercionSite::Return, resultType, synBoundStorageExpr); + subVisitor.coerce(CoercionSite::Return, resultType, synBoundStorageExpr, getSink()); auto synReturn = m_astBuilder->create<ReturnStmt>(); synReturn->expression = coercedMemberRef; @@ -8092,7 +8093,7 @@ void SemanticsDeclBodyVisitor::visitEnumCaseDecl(EnumCaseDecl* decl) if (auto initExpr = decl->tagExpr) { initExpr = CheckTerm(initExpr); - initExpr = coerce(CoercionSite::General, tagType, initExpr); + initExpr = coerce(CoercionSite::General, tagType, initExpr, getSink()); // We want to enforce that this is an integer constant // expression. @@ -9139,7 +9140,7 @@ void SemanticsDeclBodyVisitor::visitParamDecl(ParamDecl* paramDecl) // actual type of the parameter. // initExpr = CheckTerm(initExpr); - initExpr = coerce(CoercionSite::Initializer, typeExpr.type, initExpr); + initExpr = coerce(CoercionSite::Initializer, typeExpr.type, initExpr, getSink()); paramDecl->initExpr = initExpr; // TODO: a default argument expression needs to @@ -9284,7 +9285,7 @@ void SemanticsDeclBodyVisitor::synthesizeCtorBodyForBases( invoke->arguments.addRange(argumentList); auto assign = m_astBuilder->create<AssignExpr>(); - assign->left = coerce(CoercionSite::Initializer, declRefType, thisExpr); + assign->left = coerce(CoercionSite::Initializer, declRefType, thisExpr, getSink()); assign->right = invoke; auto stmt = m_astBuilder->create<ExpressionStmt>(); |
