-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parse enclosing (Pos|Neg)Op around numeric literals as sign (#638)
* Fix #505 in the parser by treating the innermost negation (also `+`) operator as a sign. The same idea is applied to expressions and patterns.
- Loading branch information
Showing
6 changed files
with
81 additions
and
24 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
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,24 @@ | ||
let _ : Int8 = -128; | ||
let _ : Int16 = -32768; | ||
let _ : Int32 = -2_147_483_648; | ||
let _ : Int64 = -9_223_372_036_854_775_808; | ||
{ | ||
assert (switch (-128 : Int8) { case (-128) { true }; case _ { false }}); | ||
func foo(i : Int8) = assert (switch i { case (-128) { true }; case _ { false }}); | ||
func bar(i : Int8) = assert (switch i { case (-128 : Int8) { true }; case _ { false }}); | ||
}; | ||
{ | ||
assert (switch (-32768 : Int16) { case (-32768) { true }; case _ { false }}); | ||
func foo(i : Int16) = assert (switch i { case (-32768) { true }; case _ { false }}); | ||
func bar(i : Int16) = assert (switch i { case (-32768 : Int16) { true }; case _ { false }}); | ||
}; | ||
{ | ||
assert (switch (-2_147_483_648 : Int32) { case (-2_147_483_648) { true }; case _ { false }}); | ||
func foo(i : Int32) = assert (switch i { case (-2_147_483_648) { true }; case _ { false }}); | ||
func bar(i : Int32) = assert (switch i { case (-2_147_483_648 : Int32) { true }; case _ { false }}); | ||
}; | ||
{ | ||
assert (switch (-9_223_372_036_854_775_808 : Int64) { case (-9_223_372_036_854_775_808) { true }; case _ { false }}); | ||
func foo(i : Int64) = assert (switch i { case (-9_223_372_036_854_775_808) { true }; case _ { false }}); | ||
func bar(i : Int64) = assert (switch i { case (-9_223_372_036_854_775_808 : Int64) { true }; case _ { false }}); | ||
}; |