Passing a binding as a parameter without $ leads to SwiftCompile failed with nonzero exit code (Swift 5.10) #75416
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
diagnostics QoI
Bug: Diagnostics Quality of Implementation
expressions
Feature: expressions
property wrappers
Feature: property wrappers
SwiftUI
Flag: Involves SwiftUI
type checker
Area → compiler: Semantic analysis
type inference
Feature: type inference
Description
I created a simple custom (bottom) sheet as an extension to View to show (and close) a bottom sheet based on a
@State
variable (did this as the Botton sheet should be used at multiple Views, possibly trigged by a@State var show: Bool
or a view model@Published var isShown: Bool
)I thought I had to call this custom bottom sheet like this:
but it results in this error message:
Error Message: Cannot convert value '$show' of type 'Binding<Bool>' to expected type 'Bool', use wrapped value instead
Suggested Fix (by Xcode - will create a separate ticket via Feedback Assistant for this) is: Remove the $
After applying this "fix", the compiler has a nonzero exit code
The correct, working code would be (not intuitive for me):
I'm not sure if the working code is the correct one by Swift language definition, but I wouldn't expect the compiler to exit without a meaningful error message.
If I can help with any additional information, please let me know!
~Heiko
Reproduction
Expected behavior
I can't tell if the "working code" is the correct one by Swift language standards, but I would expect a meaningful error message from the compiler instead of existing with a nonzero code and no information.
Environment
swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0
Additional information
No response
The text was updated successfully, but these errors were encountered: