syntax icon indicating copy to clipboard operation
syntax copied to clipboard

Spread operator for nested field updates

Open jey opened this issue 4 years ago • 1 comments

When using ReScript syntax in BuckleScript 9.0.2, I currently have to write expressions like this to create a copy of a record x with an updated nested field value:

{...x, fields: {...x.fields, lookingFor: { ...x.fields.lookingFor, friends: value }}}

It would be simpler and nicer to achieve the same effect through:

{...x, fields.lookingFor.friends: value }

jey avatar Apr 08 '21 22:04 jey

moved to syntax repo since this needs some syntax update. Previous discussions: https://github.com/ocaml/ocaml/pull/291 I am generally in favor of this feature (implemented in the front-end)

bobzhang avatar Apr 09 '21 01:04 bobzhang

The rescript-lang/syntax repo is obsolete and will be archived soon. If this issue is still relevant, please reopen in the compiler repo (https://github.com/rescript-lang/rescript-compiler) or comment here to ask for it to be moved. Thank you for your contributions.

stale[bot] avatar May 28 '23 23:05 stale[bot]