Skip to content

Commit 055b812

Browse files
committed
Fix tests.
1 parent b49e543 commit 055b812

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

source/slang/slang-check-overload.cpp

+15-6
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,14 @@ namespace Slang
263263
//
264264
bool success = true;
265265

266+
auto maybeReportGeneralError = [&]()
267+
{
268+
if (context.mode != OverloadResolveContext::Mode::JustTrying)
269+
{
270+
getSink()->diagnose(context.loc, Diagnostics::cannotSpecializeGeneric, candidate.item.declRef);
271+
}
272+
};
273+
266274
Index aa = 0;
267275
for (auto memberRef : getMembers(m_astBuilder, genericDeclRef))
268276
{
@@ -287,7 +295,10 @@ namespace Slang
287295
// or this reference is ill-formed.
288296
auto substType = typeParamRef.substitute(m_astBuilder, typeParamRef.getDecl()->initType.type);
289297
if (!substType)
298+
{
299+
maybeReportGeneralError();
290300
return false;
301+
}
291302
checkedArgs.add(substType);
292303
continue;
293304
}
@@ -355,7 +366,10 @@ namespace Slang
355366
ConstantFoldingCircularityInfo newCircularityInfo(valParamRef.getDecl(), nullptr);
356367
auto defaultVal = tryConstantFoldExpr(valParamRef.substitute(m_astBuilder, valParamRef.getDecl()->initExpr), ConstantFoldingKind::CompileTime, &newCircularityInfo);
357368
if (!defaultVal)
369+
{
370+
maybeReportGeneralError();
358371
return false;
372+
}
359373
checkedArgs.add(defaultVal);
360374
continue;
361375
}
@@ -476,12 +490,7 @@ namespace Slang
476490

477491
case OverloadCandidate::Flavor::Generic:
478492
{
479-
bool succ = TryCheckGenericOverloadCandidateTypes(context, candidate);
480-
if (!succ && context.mode != OverloadResolveContext::Mode::JustTrying)
481-
{
482-
getSink()->diagnose(context.loc, Diagnostics::cannotSpecializeGeneric, candidate.item.declRef);
483-
}
484-
return succ;
493+
return TryCheckGenericOverloadCandidateTypes(context, candidate);
485494
}
486495
default:
487496
SLANG_UNEXPECTED("unknown flavor of overload candidate");

0 commit comments

Comments
 (0)