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: add assignment, bit, and boolean operators #144

Merged
merged 1 commit into from
Apr 30, 2020

Conversation

Wodann
Copy link
Collaborator

@Wodann Wodann commented Apr 29, 2020

This PR adds:

  • bool assignment operator
  • struct assignment operator (both for struct(value) and struct(gc))
  • bool and/or (a && b || c)
  • bitwise and/or/xor operations for all integer types and bool (a | b & c, a |= b, a &= b)
  • left-shift and right-shift (-assignment) operations for all integer types ( a >> b, a << b, a >>= b, a <<= b)

Tasks that were not done yet, but should be in a future PR:

  • Add tests for operator errors
  • left-shift and right-shift operations should work for all combinations of integer types. Currently it only works when the same integer type is used on the lhs and rhs of the expression. This is currently impossible as a result of this Diagnostic

[discussion] Do we want to use the ^ sign for bitwise xor or the power operator? We've decided to use the ^ sign for bitwise xor

@Wodann Wodann requested a review from baszalmstra April 29, 2020 22:32
@Wodann Wodann self-assigned this Apr 29, 2020
@codecov
Copy link

codecov bot commented Apr 29, 2020

Codecov Report

Merging #144 into master will increase coverage by 0.21%.
The diff coverage is 84.16%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #144      +/-   ##
==========================================
+ Coverage   82.04%   82.26%   +0.21%     
==========================================
  Files         160      160              
  Lines       10826    11022     +196     
==========================================
+ Hits         8882     9067     +185     
- Misses       1944     1955      +11     
Impacted Files Coverage Δ
crates/mun_syntax/src/tests/lexer.rs 100.00% <ø> (ø)
crates/mun_syntax/src/parsing/parser.rs 82.35% <50.00%> (+1.43%) ⬆️
crates/mun_syntax/src/syntax_kind/generated.rs 65.31% <54.16%> (+1.42%) ⬆️
crates/mun_codegen/src/ir/body.rs 84.80% <79.68%> (+2.23%) ⬆️
crates/mun_hir/src/ty/op.rs 83.33% <88.88%> (+6.06%) ⬆️
crates/mun_hir/src/expr.rs 88.70% <90.90%> (+0.08%) ⬆️
crates/mun_codegen/src/test.rs 98.11% <100.00%> (+0.52%) ⬆️
crates/mun_hir/src/builtin_type.rs 50.94% <100.00%> (+1.92%) ⬆️
crates/mun_hir/src/ty/infer.rs 73.67% <100.00%> (+0.12%) ⬆️
crates/mun_syntax/src/ast/expr_extensions.rs 92.13% <100.00%> (+0.67%) ⬆️
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f1b49f2...78c9169. Read the comment docs.

Copy link
Collaborator

@baszalmstra baszalmstra left a comment

Choose a reason for hiding this comment

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

Personally I think we should use ^ for xor.

This PR looks great! Very well done!! 👍

@Wodann
Copy link
Collaborator Author

Wodann commented Apr 30, 2020

I agree. In that case I will add ^ and ^= for xor.

boolean and struct assignment were added, as well as boolean and/or and
bitwise and/or/xor/shiftleft/shiftright operations
@Wodann
Copy link
Collaborator Author

Wodann commented Apr 30, 2020

I've added the bitwise xor operator as well as the left-shift and right-shift operators. For scrutiny, could you please check the changed files @baszalmstra ?

@baszalmstra
Copy link
Collaborator

Still looks good to me!

@Wodann Wodann merged commit 0df0317 into mun-lang:master Apr 30, 2020
@Wodann Wodann added this to the Mun v0.2 milestone May 14, 2020
@Wodann Wodann deleted the feature/all-operators branch May 14, 2020 15:11
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