-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inference for lambda argument and result types (#40)
Closes #36
- Loading branch information
1 parent
1cdce7b
commit 061002e
Showing
17 changed files
with
218 additions
and
67 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,6 +1,6 @@ | ||
fn main() { | ||
let local = 10; | ||
let assign_capture = fn () { | ||
let assign_capture = \() { | ||
set local = 20; | ||
}; | ||
{} | ||
|
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,6 +1,15 @@ | ||
fn main() -> i32 { | ||
let f = fn () -> f32 { | ||
return 10; | ||
let f = \() -> i32 { | ||
return 10.0; | ||
}; | ||
return 10.0; | ||
let wrong_return : fn (i32) -> i32 = \(x) { | ||
x | ||
}; | ||
let wrong_param : fn (i32) -> i32 = \(x : f32) { | ||
return x + 1.0; | ||
}; | ||
let wrong_param_count : fn (i32) -> i32 = \(x, y) { | ||
return x + y; | ||
}; | ||
return 42; | ||
} |
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,2 +1,2 @@ | ||
global x : i32 = 10.0 | ||
global my_fn : fn (i32) -> i32 = fn (x : f32) -> f32 { x } | ||
global my_fn : fn (i32) -> i32 = \(x : f32) -> f32 { x } |
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 |
---|---|---|
@@ -1,16 +1,20 @@ | ||
import log : fn (i32) -> unit from log | ||
|
||
fn inferred() -> i32 { | ||
let f : fn (i32, f32) -> i32 = \(x, y) { x + 2 }; | ||
f(1, 2.0) | ||
} | ||
|
||
fn main() { | ||
let x = (fn (x : i32) -> i32 { x + 1 })(10); | ||
let x = (\(x : i32) -> i32 { x + 1 })(10); | ||
log(x); | ||
|
||
let twice = { | ||
fn (f : fn (i32) -> i32) -> fn(i32) -> i32 { | ||
fn (x : i32) -> i32 { | ||
f(f(x)) | ||
} | ||
} | ||
let twice = \(f : fn (i32) -> i32) -> fn(i32) -> i32 { | ||
\(x : i32) -> i32 { | ||
f(f(x)) | ||
} | ||
}; | ||
let add1 = fn (x : i32) -> i32 { x + 1 }; | ||
log(twice(add1)(3)) | ||
let add1 = \(x : i32) -> i32 { x + 1 }; | ||
log(twice(add1)(3)); | ||
log(inferred()); | ||
} |
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 |
---|---|---|
|
@@ -16,6 +16,7 @@ exit_code: 0 | |
----- stdout ----- | ||
11 | ||
5 | ||
3 | ||
0 | ||
|
||
----- stderr ----- |
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
Oops, something went wrong.