-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show deprecation on arithmetic word operations (#2339)
next step in the plan of #1824 (comment) should be merged after #2326 Add a migration guide to the users guide.
- Loading branch information
Showing
15 changed files
with
333 additions
and
83 deletions.
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.