-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from ditto-lang/add-match-expressions
- Loading branch information
Showing
36 changed files
with
1,173 additions
and
44 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
8 changes: 8 additions & 0 deletions
8
crates/ditto-checker/golden-tests/type-errors/match_unification_error_0.ditto
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,8 @@ | ||
module Test exports (..); | ||
|
||
type Foo = Foo; | ||
type Bar = Bar; | ||
|
||
nah = | ||
match Foo with | ||
| Bar -> unit; |
12 changes: 12 additions & 0 deletions
12
crates/ditto-checker/golden-tests/type-errors/match_unification_error_0.error
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,12 @@ | ||
|
||
× types don't unify | ||
╭─[golden:5:1] | ||
5 │ | ||
6 │ nah = | ||
7 │ match Foo with | ||
8 │ | Bar -> unit; | ||
· ─┬─ | ||
· ╰── here | ||
╰──── | ||
help: expected Foo | ||
got Bar |
10 changes: 10 additions & 0 deletions
10
crates/ditto-checker/golden-tests/type-errors/match_unification_error_1.ditto
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,10 @@ | ||
module Test exports (..); | ||
|
||
type Maybe(a) = Just(a) | Nothing; | ||
type Foo = Foo; | ||
type Bar = Bar; | ||
|
||
nah = (maybe_foo : Maybe(Foo)) -> | ||
match maybe_foo with | ||
| Just(Bar) -> unit | ||
| Nothing -> unit; |
13 changes: 13 additions & 0 deletions
13
crates/ditto-checker/golden-tests/type-errors/match_unification_error_1.error
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,13 @@ | ||
|
||
× types don't unify | ||
╭─[golden:6:1] | ||
6 │ | ||
7 │ nah = (maybe_foo : Maybe(Foo)) -> | ||
8 │ match maybe_foo with | ||
9 │ | Just(Bar) -> unit | ||
· ─┬─ | ||
· ╰── here | ||
10 │ | Nothing -> unit; | ||
╰──── | ||
help: expected Foo | ||
got Bar |
8 changes: 8 additions & 0 deletions
8
crates/ditto-checker/golden-tests/type-errors/match_unification_error_2.ditto
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,8 @@ | ||
module Test exports (..); | ||
|
||
type Maybe(a) = Just(a) | Nothing; | ||
|
||
nah = (maybe_foo : Maybe(Int)) -> | ||
match maybe_foo with | ||
| Just(a, b) -> unit | ||
| Nothing -> unit; |
11 changes: 11 additions & 0 deletions
11
crates/ditto-checker/golden-tests/type-errors/match_unification_error_2.error
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 @@ | ||
|
||
× wrong number of arguments | ||
╭─[golden:4:1] | ||
4 │ | ||
5 │ nah = (maybe_foo : Maybe(Int)) -> | ||
6 │ match maybe_foo with | ||
7 │ | Just(a, b) -> unit | ||
· ─────┬──── | ||
· ╰── this expects 1 argument | ||
8 │ | Nothing -> unit; | ||
╰──── |
8 changes: 8 additions & 0 deletions
8
crates/ditto-checker/golden-tests/type-errors/match_unification_error_3.ditto
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,8 @@ | ||
module Test exports (..); | ||
|
||
type Maybe(a) = Just(a) | Nothing; | ||
|
||
nah = (maybe_foo : Maybe(Int)) -> | ||
match maybe_foo with | ||
| Just -> unit | ||
| Nothing -> unit; |
11 changes: 11 additions & 0 deletions
11
crates/ditto-checker/golden-tests/type-errors/match_unification_error_3.error
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 @@ | ||
|
||
× wrong number of arguments | ||
╭─[golden:4:1] | ||
4 │ | ||
5 │ nah = (maybe_foo : Maybe(Int)) -> | ||
6 │ match maybe_foo with | ||
7 │ | Just -> unit | ||
· ──┬─ | ||
· ╰── this expects 1 argument | ||
8 │ | Nothing -> unit; | ||
╰──── |
8 changes: 8 additions & 0 deletions
8
crates/ditto-checker/golden-tests/type-errors/match_unification_error_4.ditto
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,8 @@ | ||
module Test exports (..); | ||
|
||
type Maybe(a) = Just(a) | Nothing; | ||
|
||
nah = (maybe_foo : Maybe(Int)) -> | ||
match maybe_foo with | ||
| Just(n) -> unit | ||
| Nothing(a) -> unit; |
10 changes: 10 additions & 0 deletions
10
crates/ditto-checker/golden-tests/type-errors/match_unification_error_4.error
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,10 @@ | ||
|
||
× wrong number of arguments | ||
╭─[golden:5:1] | ||
5 │ nah = (maybe_foo : Maybe(Int)) -> | ||
6 │ match maybe_foo with | ||
7 │ | Just(n) -> unit | ||
8 │ | Nothing(a) -> unit; | ||
· ─────┬──── | ||
· ╰── this expects no arguments | ||
╰──── |
8 changes: 8 additions & 0 deletions
8
crates/ditto-checker/golden-tests/type-errors/match_unification_error_5.ditto
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,8 @@ | ||
module Test exports (..); | ||
|
||
type Maybe(a) = Just(a) | Nothing; | ||
|
||
nah = (maybe_foo : Maybe(Int)): Int -> | ||
match maybe_foo with | ||
| Just(n) -> unit | ||
| Nothing -> unit; |
13 changes: 13 additions & 0 deletions
13
crates/ditto-checker/golden-tests/type-errors/match_unification_error_5.error
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,13 @@ | ||
|
||
× types don't unify | ||
╭─[golden:4:1] | ||
4 │ | ||
5 │ nah = (maybe_foo : Maybe(Int)): Int -> | ||
6 │ match maybe_foo with | ||
7 │ | Just(n) -> unit | ||
· ──┬─ | ||
· ╰── here | ||
8 │ | Nothing -> unit; | ||
╰──── | ||
help: expected Int | ||
got Unit |
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
Oops, something went wrong.