Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Could not decide which case to select" when making copy of union with object spread #7235

Closed
cakoose opened this issue Dec 5, 2018 · 2 comments

Comments

@cakoose
Copy link
Contributor

cakoose commented Dec 5, 2018

// @flow
type Union =
  {type: 'A', a: number} |
  {type: 'B', b: string};

function f(u: Union): Union {
  return {...u};  // spurious error
}

From flow.org/try:

7:   return {...u};
            ^ Could not decide which case to select. Since case 1 [1] may work but if it doesn't case 2 [2] looks promising too. To fix add a type annotation to .a [3] or to .type [3].
  References:
  3:   {type: 'A', a: number} |
       ^ [1]
  4:   {type: 'B', b: string};
       ^ [2]
  7:   return {...u};
              ^ [3]
@villesau
Copy link
Contributor

This will fix the issue: #7298

@nmote
Copy link
Contributor

nmote commented Oct 25, 2019

This no longer errors in master

@nmote nmote closed this as completed Oct 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants