Skip to content

Commit 6c36d66

Browse files
committed
Fix issue 19465 - improve 'cannot uniquely infer foreach argument types' diagnostic
Add supplemental error messages explaining why no opApply overload matched a foreach statement's parameters (parameter count mismatch, qualifier/mutability mismatch, or explicit type mismatch), instead of the previous generic error with no further detail. The added diagnostics are only printed when no more specific error (e.g. ambiguous overload match) was already reported for the same failure, to avoid duplicating existing diagnostics.
1 parent ff23268 commit 6c36d66

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

compiler/src/dmd/opover.d

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,16 +1564,13 @@ private FuncDeclaration findBestOpApplyMatch(Expression ethis, FuncDeclaration f
15641564
return fd_best;
15651565
}
15661566

1567-
/**
1568-
* Print supplemental diagnostics explaining why no `opApply` overload
1569-
* matched the `foreach` statement's parameters, to clarify the generic
1570-
* "cannot uniquely infer foreach argument types" error (issue 19465).
1571-
* Only call this when no more-specific error (e.g. ambiguity) was
1572-
* already printed for the same failure.
1567+
/******************************
1568+
* Print supplemental messages explaining why no opApply overload
1569+
* matched the foreach parameters.
15731570
* Params:
1574-
* fstart = first opApply overload (start of overload chain)
1575-
* parameters = foreach parameters, as written (types may be missing)
1576-
* aggrMod = mutability qualifier of the foreach aggregate
1571+
* fstart = first opApply overload
1572+
* parameters = foreach parameters
1573+
* aggrMod = mutability of the foreach aggregate
15771574
*/
15781575
void explainForeachArgMismatch(FuncDeclaration fstart, Parameters* parameters, MOD aggrMod)
15791576
{

0 commit comments

Comments
 (0)