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

Add overload for unary ! operator to call std::ops::Not #5000

Closed
TomAFrench opened this issue May 8, 2024 · 2 comments · Fixed by #5423
Closed

Add overload for unary ! operator to call std::ops::Not #5000

TomAFrench opened this issue May 8, 2024 · 2 comments · Fixed by #5423

Comments

@TomAFrench
Copy link
Member

After #4999 we'll have a negation trait, we should allow calling this through an operator overload similar to how we do for arithmetic operations.

@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir May 8, 2024
@TomAFrench
Copy link
Member Author

@asterite This could also be a good issue to take a look at once you have bandwidth. We've got operator overloads implemented for infix operators but not unary operators.

We'd only need to implement this in the elaborator so changes to this file would be sufficient afaik (you can also see the infix implementation in there).

@TomAFrench
Copy link
Member Author

TomAFrench commented Jun 25, 2024

I mention the elaborator as the legacy type-checking pass also implements trait dispatch and without re-implementing it there you may encounter some test case failures on here and we don't need to worry about fixing those.

github-merge-queue bot pushed a commit that referenced this issue Jul 10, 2024
# Description

## Problem

Resolves #5000

## Summary

Allows `impl Not` and `impl Neg` to be picked up at runtime.

Note that this doesn't work yet at comptime: I'd prefer to do it in a
separate PR (mainly to keep PR smaller, but also because I'm not sure
how to test it).

## Additional Context

None.

## Documentation

Is documentation needed for this?

Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[For Experimental Features]** Documentation to be submitted in a
separate PR.

# PR Checklist\*

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.

---------

Co-authored-by: jfecher <[email protected]>
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

1 participant