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

feat(compiler): Allow arrays to do binary operation assignment #1928

Merged
merged 2 commits into from
Jan 28, 2024

Conversation

renatoalencar
Copy link
Contributor

Closes #1915

Following the same semantics as record set, array accesses should allow to make use of shorthand binary operation assignments like +=.

arr[0] += 1 currently throws a syntax error, this should fix it.

@ospencer
Copy link
Member

Hey @renatoalencar! Apologies for the late response. This mostly looks good—would you mind adding a couple of tests for this?

@renatoalencar
Copy link
Contributor Author

Hey @renatoalencar! Apologies for the late response. This mostly looks good—would you mind adding a couple of tests for this?

Sure, no problem. I'll add another tests, I'm not sure what would be nice to cover.

@ospencer
Copy link
Member

I realized that we don't really have any tests that currently directly test regular binary assignments in the suite. Maybe some simple tests that just make sure we don't break it in the future; maybe one for each operator in https://github.com/grain-lang/grain/blob/d747d541dab3e2437c33fe224a92843f1027a226/compiler/test/suites/arrays.re.

@phated
Copy link
Member

phated commented Jan 27, 2024

@ospencer can you help @renatoalencar with the parser exhaustiveness errors here?

@ospencer
Copy link
Member

Done. This will also need support in the formatter, but I would wait for #1976 to land before attempting that.

@phated
Copy link
Member

phated commented Jan 27, 2024

@ospencer does that mean you want to hold this PR or just open a follow up issue?

@ospencer
Copy link
Member

We can open an issue.

@phated phated added this pull request to the merge queue Jan 28, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 28, 2024
@phated phated added this pull request to the merge queue Jan 28, 2024
Merged via the queue into grain-lang:main with commit 8a335ae Jan 28, 2024
12 checks passed
@renatoalencar
Copy link
Contributor Author

renatoalencar commented Jan 29, 2024

@ospencer can you help @renatoalencar with the parser exhaustiveness errors here?

I was about to get into Discord to ask for help on this

@renatoalencar renatoalencar deleted the fix/array-binary-assign branch January 29, 2024 17:44
@ospencer
Copy link
Member

Feel free to join us there! 😄

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.

Syntax: Support addition on arr
3 participants