You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This introduces bugs and almost defeats the purpose of compile-time errors. To prevent the program compiling successfully without producing an error for a type like Foo:
structFoo:View{}
There are two options - that I can think of:
Add another _Never conditional conformances - to a dummy type like _Never that will require disambiguating when omitting the body:
enum_Never:View{varbody:Never{fatalError()}}extensionViewwhere Body ==_Never{varbody:_Never{fatalError("Can't access body of Never View.")}}
That is a hack though and the error ("Type 'H' does not conform to protocol 'Block'") doesn't provide a fix possibly leaving a novice developer confused.
Remove the extension that provides an automatic conformance when Body is of type Never and move that behaviour to the ViewDeferredToRenderer protocol - or to an underlying view protocol such as _StuctureView, _View, _FatalView:
protocol_StuctureView:Viewwhere Body ==Never{}extension_StuctureView{varbody:Never{fatalError("Can't access body of Structure View.")}}
That IMO is the best option, as it avoids automatic type-inference altogether and provides a useful error message - that offers a fix.
The text was updated successfully, but these errors were encountered:
Thank you @filip-sakel, this is a great point, primarily because it also highlights the incompatibility with SwiftUI, it is now fixed in the main branch.
This introduces bugs and almost defeats the purpose of compile-time errors. To prevent the program compiling successfully without producing an error for a type like
Foo
:There are two options - that I can think of:
Add another _Never conditional conformances - to a dummy type like
_Never
that will require disambiguating when omitting the body:That is a hack though and the error ("Type 'H' does not conform to protocol 'Block'") doesn't provide a fix possibly leaving a novice developer confused.
Remove the extension that provides an automatic conformance when Body is of type
Never
and move that behaviour to the ViewDeferredToRenderer protocol - or to an underlying view protocol such as _StuctureView, _View, _FatalView:That IMO is the best option, as it avoids automatic type-inference altogether and provides a useful error message - that offers a fix.
The text was updated successfully, but these errors were encountered: