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

fix(compiler): Fix array infix assign semantics #2080

Merged
merged 1 commit into from
Mar 29, 2024
Merged

Conversation

ospencer
Copy link
Member

Closes #1988

Copy link
Member

@spotandjake spotandjake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, as a note my pr that implemented infix formatting still serves a role as in cases like:

arr[1] = arr[1] + 1

We are still going to want the formatter to convert those to infix automatically.

@ospencer
Copy link
Member Author

I didn't implement that because of the arr[foo()] case. I'm not sure if we want to do that change when it's semantically correct, because it's pretty annoying to detect.

@spotandjake
Copy link
Member

I didn't implement that because of the arr[foo()] case. I'm not sure if we want to do that change when it's semantically correct, because it's pretty annoying to detect.

Detecting the simple case of an identifier or constant is easy I just don't think we should go beyond that .

@ospencer
Copy link
Member Author

I'll do that in a follow-on PR.

@spotandjake
Copy link
Member

Sounds good

@ospencer
Copy link
Member Author

I'll also do a follow-on PR to use this same format for regular infix assignment and record infix assignment.

Error(
infix.exp_loc,
env,
Arity_mismatch(expand_head(env, infix.exp_type), None),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be an Impossible?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not, because you can redefine what the infix operators do, and we don't stop you from making one take a number of arguments other than two. (You wouldn't be able to call it with the infix syntax, but you could call it as a regular function.)

Copy link
Member

@marcusroberts marcusroberts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ospencer ospencer added this pull request to the merge queue Mar 29, 2024
Merged via the queue into main with commit bea360d Mar 29, 2024
12 checks passed
@ospencer ospencer deleted the oscar/array-set branch March 29, 2024 22:30
@github-actions github-actions bot mentioned this pull request Mar 29, 2024
Copy link
Member

@peblair peblair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already merged, but also looks good to me

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.

Add formatting support for array infix assignment
5 participants