@@ -263,6 +263,14 @@ namespace Slang
263
263
//
264
264
bool success = true ;
265
265
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
+
266
274
Index aa = 0 ;
267
275
for (auto memberRef : getMembers (m_astBuilder, genericDeclRef))
268
276
{
@@ -287,7 +295,10 @@ namespace Slang
287
295
// or this reference is ill-formed.
288
296
auto substType = typeParamRef.substitute (m_astBuilder, typeParamRef.getDecl ()->initType .type );
289
297
if (!substType)
298
+ {
299
+ maybeReportGeneralError ();
290
300
return false ;
301
+ }
291
302
checkedArgs.add (substType);
292
303
continue ;
293
304
}
@@ -355,7 +366,10 @@ namespace Slang
355
366
ConstantFoldingCircularityInfo newCircularityInfo (valParamRef.getDecl (), nullptr );
356
367
auto defaultVal = tryConstantFoldExpr (valParamRef.substitute (m_astBuilder, valParamRef.getDecl ()->initExpr ), ConstantFoldingKind::CompileTime, &newCircularityInfo);
357
368
if (!defaultVal)
369
+ {
370
+ maybeReportGeneralError ();
358
371
return false ;
372
+ }
359
373
checkedArgs.add (defaultVal);
360
374
continue ;
361
375
}
@@ -476,12 +490,7 @@ namespace Slang
476
490
477
491
case OverloadCandidate::Flavor::Generic:
478
492
{
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);
485
494
}
486
495
default :
487
496
SLANG_UNEXPECTED (" unknown flavor of overload candidate" );
0 commit comments