-
Notifications
You must be signed in to change notification settings - Fork 8
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 shift operators #23
Conversation
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #23 +/- ##
==========================================
+ Coverage 58.25% 59.61% +1.36%
==========================================
Files 2 2
Lines 103 104 +1
==========================================
+ Hits 60 62 +2
+ Misses 43 42 -1
☔ View full report in Codecov by Sentry. |
@Gnimuc Could you please take a look at this? Thanks! |
src/operators.jl
Outdated
|
||
for op in (:+, :-, :&, :|, :xor, :(==)) | ||
for op in (:+, :-, :&, :|, :xor, :(==), :<<, :>>, :>>>) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
>>
and <<
are OK, but I don't think C supports >>>
.
ref: https://en.cppreference.com/w/c/language/operator_arithmetic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Users can still define >>>
in their own package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait, could you confirm the promotion behavior between Julia's >>
and C's >>
is identical?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From https://en.cppreference.com/w/c/language/operator_arithmetic subsection "Shift operators" it indeed agrees with Julia's shift operators.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to add those examples as test cases.
https://godbolt.org/z/W194b656a
Here, we are testing against C's promotion behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Also, I'd like to release this feature in 0.5.x. This package is indirectly used by many wrapper packages generated by Clang.jl. And if the downstream packages have defined these methods in their own code base, something might be broken. The download number scares me... |
Thanks! |
Could 8533026 please be registered now that this PR is merged? |
What in here is breaking? |
in case someone defined their own shift operators that are not compatible with C's behavior... |
This PR adds support for C's shift operators.
This feature is needed because Clang.jl can emit code like the test I added, which is a method error otherwise.