Skip to content

Wrong type inferred for closure when returned from function #4929

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
veddan opened this issue Feb 14, 2013 · 3 comments
Closed

Wrong type inferred for closure when returned from function #4929

veddan opened this issue Feb 14, 2013 · 3 comments
Labels
A-type-system Area: Type system E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@veddan
Copy link
Contributor

veddan commented Feb 14, 2013

fn make_adder(x: int) -> @fn(int) -> int { |y| x + y }

The above function gives a compile error:
mismatched types: expected @fn(int) -> int but found &fn(int) -> int (expected @ closure, found & closure)

If I change the expression syntax into an explicit return:

fn make_adder(x: int) -> @fn(int) -> int { return |y| x + y; }

the code compiler (and runs) without error.

@catamorphism
Copy link
Contributor

Re-nominating for milestone 5 (production-ready).

graydon added a commit to graydon/rust that referenced this issue Aug 2, 2013
@emberian
Copy link
Member

emberian commented Aug 5, 2013

Fixed; can be closed pending #8209

@graydon
Copy link
Contributor

graydon commented Aug 15, 2013

accepted for production-ready milestone

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-type-system Area: Type system E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

No branches or pull requests

4 participants