Type checker fails when calling a function with an Optional<() -> Void>
ternary expression as a parameter
#78113
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
diagnostics QoI
Bug: Diagnostics Quality of Implementation
expressions
Feature: expressions
failed to produce diagnostic
Bug → internal error: Failed to produce diagnostic for expression
type checker
Area → compiler: Semantic analysis
Description
No response
Reproduction
When compiling the following, the compiler fails with the error
Type of expression is ambiguous without a type annotation
The above issue also leads to another diagnostic when the function call is within a SwiftUI ViewBuilder.
Here the compiler returns the error
Failed to produce diagnostic for expression; please submit a bug report (https://swift.org/contributing/#reporting-bugs)
on the line ofvar body
POC swift package:
POC.zip
Expected behavior
I expected the code to successfully compile without any warnings or errors
Environment
The issues mentioned above happens when compiling the attached POC in Xcode 16.1 (16B40), Xcode 16.2 (16C5031c), and with
swift build
from the terminal. The problem does not seem to occur when compiling withswiftc
Output of
swiftc -version
:Additional information
The problem first occurred in a file similar to the SwiftUI example above, after a class containing the equivalent of
someFunc
had been annotated with @ MainActorThe text was updated successfully, but these errors were encountered: