From 2275e18fc052239fe67f3fda68252ad92bb83ca9 Mon Sep 17 00:00:00 2001 From: Jay Kwak <82421531+jkwak-work@users.noreply.github.com> Date: Thu, 15 May 2025 01:55:17 +0000 Subject: 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. --- source/slang/slang-check-stmt.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/slang/slang-check-stmt.cpp') diff --git a/source/slang/slang-check-stmt.cpp b/source/slang/slang-check-stmt.cpp index 0e5ed92aa..2dc8c2685 100644 --- a/source/slang/slang-check-stmt.cpp +++ b/source/slang/slang-check-stmt.cpp @@ -255,7 +255,7 @@ Expr* SemanticsVisitor::checkPredicateExpr(Expr* expr) } Expr* e = expr; e = CheckTerm(e); - e = coerce(CoercionSite::General, m_astBuilder->getBoolType(), e); + e = coerce(CoercionSite::General, m_astBuilder->getBoolType(), e, getSink()); return e; } @@ -408,7 +408,7 @@ void SemanticsStmtVisitor::visitCaseStmt(CaseStmt* stmt) // Check that the type for the `case` is consistent with the type for the `switch`. auto expr = CheckExpr(stmt->expr); - expr = coerce(CoercionSite::Argument, switchStmt->condition->type, expr); + expr = coerce(CoercionSite::Argument, switchStmt->condition->type, expr, getSink()); // coerce to type being switch on, and ensure that value is a compile-time constant // The Vals in the AST are pointer-unique, making them easy to check for duplicates @@ -574,7 +574,7 @@ void SemanticsStmtVisitor::visitReturnStmt(ReturnStmt* stmt) if (!m_parentLambdaExpr && expectedReturnType) { stmt->expression = - coerce(CoercionSite::Return, expectedReturnType, stmt->expression); + coerce(CoercionSite::Return, expectedReturnType, stmt->expression, getSink()); } } } -- cgit v1.2.3