Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
typeck: Take more care to pass down expected types
This helps with prototype inference and avoids some 'must be known in this context' errors.
- Loading branch information
Showing
2 changed files
with
98 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Tests the passing down of expected types through boxing and | ||
// wrapping in a record or tuple. (The a.x would complain about 'this | ||
// type must be known in this context' if the passing down doesn't | ||
// happen.) | ||
|
||
fn eat_tup(_r: ~@(int, fn@({x: int, y: int}) -> int)) {} | ||
fn eat_rec(_r: @~{a: int, b: fn@({x: int, y: int}) -> int}) {} | ||
|
||
fn main() { | ||
eat_tup(~@(10, {|a| a.x})); | ||
eat_rec(@~{a: 10, b: {|a| a.x}}); | ||
} |