-
Notifications
You must be signed in to change notification settings - Fork 105
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
Show deprecation on arithmetic word operations #2339
Merged
Merged
Changes from all commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
0e0b447
Value.Numerics: Refactoring to prepare word deprecation
nomeata 42b046c
Forgotten
nomeata 79a92ab
Keep mo:prim compatible
nomeata a0c9fd7
Update test output
nomeata 095b32d
Fix of_string for words
nomeata c36a8d4
Add bit-operations to nat and int, and wrapping operations to all
nomeata 8ff5032
Fix wrong name for Nat64Wrap primop
nomeata 7cd401f
Update src/mo_values/operator.ml
nomeata 68af7c7
Forgot to actually support them operators
nomeata b040f02
Empty line be gone
nomeata 806ba92
Update src/codegen/compile.ml
nomeata 9514c35
Use right PowOp for Words
nomeata ce49293
Do not even begin to support +>> on IntN and NatN
nomeata 36fb907
Shorter prefix: Just w
nomeata 2e9e8a2
Fixup shorter prefix
nomeata 60b8293
Update src/mo_values/numerics.ml
nomeata 178da47
Merge remote-tracking branch 'origin/joachim/value-refactor' into joa…
nomeata f90a256
Simplify num_conv_wrap_prim
nomeata 37f4399
Merge branch 'joachim/value-refactor' into joachim/new-bit-ops
nomeata 2d8e324
Typos
nomeata 1a3e6e1
Merge branch 'joachim/value-refactor' into joachim/new-bit-ops
nomeata c211c5d
Update src/lowering/desugar.ml
nomeata 3a0ab52
Update src/lowering/desugar.ml
nomeata 3e5959a
Merge branch 'master' of github.com:dfinity/motoko into joachim/value…
nomeata 159a47b
Merge branch 'joachim/value-refactor' into joachim/new-bit-ops
nomeata a35e51c
Post-squash merge of origin/master
nomeata 4e74f44
Changelog
nomeata ac3c889
Cherry-pick users’s guide
nomeata 735c0f4
Deleted too much
nomeata c84c04f
Unrelated typo
nomeata dd6ef23
Already provide charToNat32/nat32ToChar in prim
nomeata 53254a2
Merge branch 'master' of github.com:dfinity/motoko into joachim/new-b…
nomeata 6fd6d70
Merge branch 'master' into joachim/new-bit-ops
nomeata 19ab1b1
Merge branch 'master' into joachim/new-bit-ops
nomeata 99d4086
Show deprecation on arithmetic word operations
nomeata 2aa9b73
Merge branch 'joachim/new-bit-ops' into joachim/warn-on-word-ops
nomeata baa7b0b
Update test output
nomeata 2bfd78c
Use wrapping ops on Word in numeric-ops.mo
nomeata ad13a79
More test suite updates
nomeata 220bbbd
User’s guide: Migration comment (and changelog)
nomeata bfdf241
More test suite updates
nomeata e347a66
Apply suggestions from code review
nomeata 52b005a
Update Changelog.md
nomeata ebfca8d
Also give deprecation warning in checking mode
nomeata c9f4eab
Typo in error_reporting.ml
nomeata 76c5ef7
More copy’n’pasta (and bad testing coverage…)
nomeata 07259ae
Merge branch 'joachim/new-bit-ops' into joachim/warn-on-word-ops
nomeata 693a117
Update doc/overview-slides.md
nomeata b462eb3
More test suite updates
nomeata 73512d6
Update perf tests
nomeata e5c1f01
Update doc/modules/language-guide/pages/basic-concepts.adoc
nomeata 7e1a2ef
Update Changelog.md
nomeata ed4ed69
Apply suggestions from code review
nomeata 4b50977
Merge branch 'master' into joachim/new-bit-ops
mergify[bot] b0f83a1
Merge branch 'joachim/new-bit-ops' into joachim/warn-on-word-ops
nomeata 7a3c39d
Remove more code fences (```)
nomeata 1a73d0e
Post-squash merge of origin/master
nomeata File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
= M0152 | ||
|
||
You are using a possibly wrapping operator (`+`, `-`, `*` or `**`) on a word | ||
type (e.g. `Word8`). The word type will be deprecated in the future, and | ||
replaced with `Nat8`, `Int8` etc. The arithmetic operations have different | ||
semantics on these types, as they trap on overflow, instead of wrapping around. | ||
to prepare the transition, you are advised to use the wrapping operators (`+%`, | ||
`-%`, `*%` and `**%`) now. This way, when you eventually switch to `Nat8` or `Int8`, | ||
these operators work as expected. | ||
|
||
See the user's guide, section on `Word` type, for more information on this transition. | ||
|
||
Erroneous code example: | ||
|
||
func add(w1 : Word8, w2 : Word8) : Word8 { w1 + w2 }; | ||
|
||
Typical fix: | ||
|
||
func add(w1 : Word8, w2 : Word8) : Word8 { w1 +% w2 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
word-ops-deprecation.mo:2.34-2.39: warning [M0152], the arithmetic operation + on Word8 is deprecated, use +% instead | ||
word-ops-deprecation.mo:3.34-3.39: warning [M0152], the arithmetic operation - on Word8 is deprecated, use -% instead | ||
word-ops-deprecation.mo:4.34-4.39: warning [M0152], the arithmetic operation * on Word8 is deprecated, use *% instead | ||
word-ops-deprecation.mo:5.34-5.40: warning [M0152], the arithmetic operation ** on Word8 is deprecated, use **% instead | ||
word-ops-deprecation.mo:6.35-6.40: warning [M0152], the arithmetic operation + on Word16 is deprecated, use +% instead | ||
word-ops-deprecation.mo:7.35-7.40: warning [M0152], the arithmetic operation - on Word16 is deprecated, use -% instead | ||
word-ops-deprecation.mo:8.35-8.40: warning [M0152], the arithmetic operation * on Word16 is deprecated, use *% instead | ||
word-ops-deprecation.mo:9.35-9.41: warning [M0152], the arithmetic operation ** on Word16 is deprecated, use **% instead | ||
word-ops-deprecation.mo:10.35-10.40: warning [M0152], the arithmetic operation + on Word32 is deprecated, use +% instead | ||
word-ops-deprecation.mo:11.35-11.40: warning [M0152], the arithmetic operation - on Word32 is deprecated, use -% instead | ||
word-ops-deprecation.mo:12.35-12.40: warning [M0152], the arithmetic operation * on Word32 is deprecated, use *% instead | ||
word-ops-deprecation.mo:13.35-13.41: warning [M0152], the arithmetic operation ** on Word32 is deprecated, use **% instead | ||
word-ops-deprecation.mo:14.35-14.40: warning [M0152], the arithmetic operation + on Word64 is deprecated, use +% instead | ||
word-ops-deprecation.mo:15.35-15.40: warning [M0152], the arithmetic operation - on Word64 is deprecated, use -% instead | ||
word-ops-deprecation.mo:16.35-16.40: warning [M0152], the arithmetic operation * on Word64 is deprecated, use *% instead | ||
word-ops-deprecation.mo:17.35-17.41: warning [M0152], the arithmetic operation ** on Word64 is deprecated, use **% instead | ||
word-ops-deprecation.mo:20.36-20.41: warning [M0152], the arithmetic operation + on Word8 is deprecated, use +% instead | ||
word-ops-deprecation.mo:21.36-21.41: warning [M0152], the arithmetic operation - on Word8 is deprecated, use -% instead | ||
word-ops-deprecation.mo:22.36-22.41: warning [M0152], the arithmetic operation * on Word8 is deprecated, use *% instead | ||
word-ops-deprecation.mo:23.36-23.42: warning [M0152], the arithmetic operation ** on Word8 is deprecated, use **% instead | ||
word-ops-deprecation.mo:24.38-24.43: warning [M0152], the arithmetic operation + on Word16 is deprecated, use +% instead | ||
word-ops-deprecation.mo:25.38-25.43: warning [M0152], the arithmetic operation - on Word16 is deprecated, use -% instead | ||
word-ops-deprecation.mo:26.38-26.43: warning [M0152], the arithmetic operation * on Word16 is deprecated, use *% instead | ||
word-ops-deprecation.mo:27.38-27.44: warning [M0152], the arithmetic operation ** on Word16 is deprecated, use **% instead | ||
word-ops-deprecation.mo:28.38-28.43: warning [M0152], the arithmetic operation + on Word32 is deprecated, use +% instead | ||
word-ops-deprecation.mo:29.38-29.43: warning [M0152], the arithmetic operation - on Word32 is deprecated, use -% instead | ||
word-ops-deprecation.mo:30.38-30.43: warning [M0152], the arithmetic operation * on Word32 is deprecated, use *% instead | ||
word-ops-deprecation.mo:31.38-31.44: warning [M0152], the arithmetic operation ** on Word32 is deprecated, use **% instead | ||
word-ops-deprecation.mo:32.38-32.43: warning [M0152], the arithmetic operation + on Word64 is deprecated, use +% instead | ||
word-ops-deprecation.mo:33.38-33.43: warning [M0152], the arithmetic operation - on Word64 is deprecated, use -% instead | ||
word-ops-deprecation.mo:34.38-34.43: warning [M0152], the arithmetic operation * on Word64 is deprecated, use *% instead | ||
word-ops-deprecation.mo:35.38-35.44: warning [M0152], the arithmetic operation ** on Word64 is deprecated, use **% instead |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
You can do this and remove the
open Type
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.
Nope, that would exclue
Prim
. And then you need extra parenthesis, which I like less than you do ;-)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.
Or put
T.
before those as well -- still a net win. :)