-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Refactor of how arrow functions are handled - Inferring types of closure params/return based on hint - Allow using `5i/5u` shorthand instead of `5i32/5u32`
- Loading branch information
1 parent
db44183
commit f23c94b
Showing
13 changed files
with
2,534 additions
and
2,870 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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,8 @@ | ||
/// fail: Expected `x` with type @fn(i32, i32): i32, but got @fn(i32, u32): i32 | ||
def foo(x: @fn(i32,i32): i32): i32 => x(1, 2) | ||
|
||
def main() { | ||
let t = foo(|a, b: u32| => a + b as i32 + 3) | ||
println(`t={t}`) | ||
} |
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 @@ | ||
/// fail: Expected `x` with type @fn(i32, i32): i32, but got @fn(i32, i32): str | ||
def foo(x: @fn(i32,i32): i32): i32 => x(1, 2) | ||
|
||
def main() { | ||
let t = foo(|a, b|: str => "hello") | ||
println(`t={t}`) | ||
} |
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,9 @@ | ||
/// fail: Expected return type i32, but got str | ||
def foo(x: @fn(i32,i32): i32): i32 => x(1, 2) | ||
|
||
def main() { | ||
// Infered type is @fn(i32, i32): i32, but we are returning str | ||
let t = foo(|a, b| => "hello") | ||
println(`t={t}`) | ||
} |
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,9 @@ | ||
/// fail: Cannot infer type, specify it explicitly | ||
def foo(x: @fn(i32,i32): i32): i32 => x(1, 2) | ||
|
||
def main() { | ||
let x = |a, b| => a + b + 3 | ||
let t = foo(x) | ||
println(`t={t}`) | ||
} |
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 @@ | ||
/// out: "t=6" | ||
def foo(x: @fn(i32,i32): i32): i32 => x(1, 2) | ||
|
||
def main() { | ||
let t = foo(|a, b| => a + b + 3) | ||
t = foo(|a, b|: i32 => a + b + 3) | ||
t = foo(|a: i32, b| => a + b + 3) | ||
t = foo(|a: i32, b: i32| => a + b + 3) | ||
t = foo(|a, b: i32| => a + b + 3) | ||
println(`t={t}`) | ||
} |
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 |
---|---|---|
|
@@ -11,4 +11,5 @@ def main() { | |
let d: i64 = -40i64 | ||
let e: f32 = 50.0f32 | ||
let f: f64 = 60.0f64 | ||
let g: i32 = 60i | ||
} |