Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/Sema/CSDiagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2107,6 +2107,11 @@ bool ContextualFailure::diagnoseAsError() {
return true;
}

case ConstraintLocator::FunctionBuilderBodyResult: {
diagnostic = *getDiagnosticFor(CTP_Initialization, toType);
break;
}

default:
return false;
}
Expand Down
6 changes: 6 additions & 0 deletions lib/Sema/CSSimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4264,6 +4264,12 @@ bool ConstraintSystem::repairFailures(
break;
}

case ConstraintLocator::FunctionBuilderBodyResult: {
conversionsOrFixes.push_back(ContextualMismatch::create(
*this, lhs, rhs, getConstraintLocator(locator)));
break;
}

default:
break;
}
Expand Down
5 changes: 5 additions & 0 deletions lib/Sema/ConstraintSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3531,6 +3531,11 @@ void constraints::simplifyLocator(Expr *&anchor,
continue;
}

case ConstraintLocator::FunctionBuilderBodyResult: {
path = path.slice(1);
break;
}

default:
// FIXME: Lots of other cases to handle.
break;
Expand Down
4 changes: 4 additions & 0 deletions test/Constraints/function_builder_diags.swift
Original file line number Diff line number Diff line change
Expand Up @@ -602,4 +602,8 @@ struct MyView {
case . // expected-error {{expected ':' after 'case'}}
} // expected-error {{expected identifier after '.' expression}}
}

@TupleBuilder var invalidConversion: Int {
"" // expected-error {{cannot convert value of type 'String' to specified type 'Int'}}
}
}