Reason: refmt errors "Record's `...` spread is not supported in pattern matches" when not matching

Created on 23 Aug 2018  路  3Comments  路  Source: reasonml/reason

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
BUG VERY DIFFICULT

All 3 comments

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

I'm working on a fix atm.

Found the problem, submitted a PR with a solution.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TrakBit picture TrakBit  路  3Comments

cristianoc picture cristianoc  路  4Comments

bobzhang picture bobzhang  路  3Comments

yunxing picture yunxing  路  4Comments

chenglou picture chenglou  路  3Comments