-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow using match statement with integers
- Loading branch information
Showing
7 changed files
with
61 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import "stdlib/io.jou" | ||
|
||
def main() -> int: | ||
match True: # Error: cannot match a value of type bool (use if/else instead) | ||
case True: | ||
printf("ya\n") | ||
return 0 |
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,11 @@ | ||
import "stdlib/io.jou" | ||
|
||
class Foo: | ||
x: int | ||
y: int | ||
|
||
def main() -> int: | ||
match Foo{x=1, y=2}: # Error: cannot match a value of type Foo | ||
case Foo{x=1, y=2}: | ||
printf("ya\n") | ||
return 0 |
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,6 @@ | ||
def bruh() -> None: | ||
# Floats and doubles usually shouldn't be == compared, so matching them | ||
# is a bad idea (unless you use "match ... with ..." syntax) | ||
match 1.0: # Error: cannot match a value of type double | ||
case 2.0: | ||
pass |
This file was deleted.
Oops, something went wrong.
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,7 @@ | ||
import "stdlib/io.jou" | ||
|
||
def main() -> int: | ||
match "hi": # Error: cannot match a value of type byte* (try adding 'with strcmp') | ||
case "ho": | ||
printf("ya\n") | ||
return 0 |