We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e30612e commit 881f521Copy full SHA for 881f521
lib/Sema/CSDiagnostics.cpp
@@ -3508,6 +3508,20 @@ bool AllowTypeOrInstanceMemberFailure::diagnoseAsError() {
3508
return true;
3509
}
3510
3511
+ // Function type has fewer arguments than expected by context:
3512
+ //
3513
+ // ```
3514
+ // func foo() {}
3515
+ // let _: (Int) -> Void = foo
3516
3517
+ if (locator->isLastElement(ConstraintLocator::ContextualType)) {
3518
+ auto &cs = getConstraintSystem();
3519
+ emitDiagnostic(anchor->getLoc(), diag::cannot_convert_initializer_value,
3520
+ getType(anchor), resolveType(cs.getContextualType()));
3521
+ // TODO: It would be great so somehow point out which arguments are missing.
3522
+ return true;
3523
+ }
3524
+
3525
return false;
3526
3527
0 commit comments