-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Typechecker: try-else improvements (#535)
* Typechecker: try-else improvements This change allows try-expressions to be used in functions which do not necessarily return a Result value, if there is an else-clause attached. * Typechecker/Compiler: Support Option try Try expressions can now work on values with type `T?`.
- Loading branch information
Showing
18 changed files
with
1,223 additions
and
52 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
val m = { | ||
a: 1, | ||
b: 2, | ||
c: 3, | ||
s: 4 | ||
} | ||
println(m.size) | ||
println(m) | ||
func some(): Int? = Some(123) | ||
func none(): Int? = None | ||
|
||
func f12(): Result<Int, Int> { | ||
var acc = 0 | ||
while acc < 10 { | ||
val x = try none() else return Some(12) | ||
acc += x | ||
} | ||
|
||
for (k, v) in m { | ||
println(k, v) | ||
Some(acc) | ||
} | ||
|
||
/// Expect: Option.Some(value: 12) | ||
println(f12()) |
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.