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

refmt errors "Record's ... spread is not supported in pattern matches" when not matching #2155

Closed
bloodyowl opened this issue Aug 23, 2018 · 3 comments

Comments

@bloodyowl
Copy link
Contributor

Code

running refmt on:

true ? (a, {...a, b: 1}) : a"

outputs

File "", line 1, characters 12-16:
Error: Record's `...` spread is not supported in pattern matches.
Explanation: you can't collect a subset of a record's field into its own record, since a record needs an explicit declaration and that subset wouldn't have one.
Solution: you need to pull out each field you want explicitly.

Errors too:

true ? ({...a, b: 1}) : a

Doesn't error:

true ? {...a, b: 1} : a
@johannth
Copy link

We're also running into this issue on bs-platform v4.0.5 in our codebase in many places.

This errors:

true ? (Update({...a, b: 1}), None) : (NoUpdate(a), None)

This doesn't error:

true ? {(Update({...a, b: 1}), None)} : (NoUpdate(a), None)

However refmt 3.3.3-macos-1 always removes the {} around the tuple so we're kind of stuck.

Can someone help us understand this issue? Is there some syntax change that we're missing or is this just a known regression that will be fixed soon? Anything that we can do to help? It's blocking us from upgrading past 4.0.1

@IwanKaramazow
Copy link
Contributor

I'm working on a fix atm.

@IwanKaramazow
Copy link
Contributor

Found the problem, submitted a PR with a solution.

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

3 participants