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

Better record spread. #3519

Merged
merged 2 commits into from
Nov 11, 2023
Merged

Better record spread. #3519

merged 2 commits into from
Nov 11, 2023

Conversation

toots
Copy link
Member

@toots toots commented Nov 10, 2023

This PR improves record spread by allowing multiple spread inside records:

  x = {foo=123}
  y = {gni="aabb"}
  test.equals({...x, ...y}, {foo=123, gni="aabb"})
  test.equals({...x, gna=3.14, ...y}, {foo=123, bla=3.14, gni="aabb"})
  test.equals(
    {...x, gna=3.14, ...y, foo="bar"}, {foo="bar", bla=3.14, gni="aabb"}
  )

Refs: #3512

toots added a commit to savonet/tree-sitter-liquidsoap that referenced this pull request Nov 10, 2023
toots added a commit to savonet/liquidsoap-prettier that referenced this pull request Nov 10, 2023
toots added a commit to savonet/codemirror-lang-liquidsoap that referenced this pull request Nov 10, 2023
@toots toots force-pushed the better-record-spread branch from a218d97 to 6b7490b Compare November 10, 2023 22:47
@vitoyucepi
Copy link
Collaborator

Hi @toots,
I think you should add more tests.

x = {foo=1}
y = {foo=2}
test.equals({...x, ...y}, {foo=2})
test.equals({...y, ...x}, {foo=1})

x = {foo=1}
y = {foo=null()}
test.equals({...x, ...y}, {foo=null()})
test.equals({...y, ...x}, {foo=1})

x = {foo=null()}
y = {foo=null()}
test.equals({...x, ...y}, {foo=null()})
test.equals({...y, ...x}, {foo=null()})

x = {foo=1}
y = {foo="a"}
test.equals({...x, ...y}, {foo="a"})
test.equals({...y, ...x}, {foo=1})

x = {foo=1}
y = {foo={bar=1}}
test.equals({...x, ...y}, {foo={bar=1}})
test.equals({...y, ...x}, {foo=1})

@toots
Copy link
Member Author

toots commented Nov 10, 2023

x = {foo=1}
y = {foo=2}
test.equals({...x, ...y}, {foo=2})
test.equals({...y, ...x}, {foo=1})

x = {foo=1}
y = {foo=null()}
test.equals({...x, ...y}, {foo=null()})
test.equals({...y, ...x}, {foo=1})

x = {foo=null()}
y = {foo=null()}
test.equals({...x, ...y}, {foo=null()})
test.equals({...y, ...x}, {foo=null()})

x = {foo=1}
y = {foo="a"}
test.equals({...x, ...y}, {foo="a"})
test.equals({...y, ...x}, {foo=1})

x = {foo=1}
y = {foo={bar=1}}
test.equals({...x, ...y}, {foo={bar=1}})
test.equals({...y, ...x}, {foo=1})

Added thanks!

@toots toots enabled auto-merge November 10, 2023 23:31
@toots toots added this pull request to the merge queue Nov 10, 2023
Merged via the queue into main with commit 6350950 Nov 11, 2023
25 checks passed
@toots toots deleted the better-record-spread branch November 11, 2023 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants