Skip to content
Discussion options

You must be logged in to vote

The behavior you're seeing is related to Swift's optional promotion and the fact that CaseLet is not in a context that can be influenced by type inference. In this case a Store<State?, Action> is passed to SwitchStore, which makes the exhaustive switch's types line up, but the CaseLet is working with a non-optional case path expression, which makes its body look for an environment object of a store of non-optional state to be hydrated with.

So the fix is to make the types line up. One option is to update the CaseLet with extraction functions that fully account for the optionality:

switch state {
case .some(.red):
  CaseLet(
    (/Feature.Color.State?.some).appending(path: /Feature.Color.S…

Replies: 1 comment 10 replies

Comment options

You must be logged in to vote
10 replies
@stephencelis
Comment options

@Muhammed9991
Comment options

@Muhammed9991
Comment options

@stephencelis
Comment options

@Muhammed9991
Comment options

Answer selected by yBuild1When2Are2xThePrice
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #2403 on August 24, 2023 05:18.