Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

infer local function return types #26414

Closed
nex3 opened this issue May 5, 2016 · 3 comments

Comments

@nex3
Copy link
Member

commented May 5, 2016

If I define a named function within a method body, that function's return type should be inferred. This matches the general style of relying on inference rather than explicit typing when possible in method bodies.

@jmesserly

This comment has been minimized.

Copy link
Contributor

commented May 5, 2016

Hah, yeah, we had a bug about this at one point over in DDC (dart-archive/dev_compiler#35).

Inference algorithms get a lot more interesting once local functions are involved :). The C# style inference we were planning (for #25490) is not powerful enough to handle them in general, IIRC. Scala might have something that handles it. There was another interesting paper which I can't find the link to at the moment, that extended colored local inference to handle functions.

That said -- if you mainly want return types and you don't need to have parameter types be inferred, then that should make it a lot easier. We should be albe to infer the same way we infer lambda expressions.

@nex3

This comment has been minimized.

Copy link
Member Author

commented May 5, 2016

Yeah, I'm referring to return types here. Inferring parameters would be cool, but I don't expect it to be possible given the way inference works in the rest of the language.

@bwilkerson bwilkerson added the P2 label May 11, 2016

@jmesserly jmesserly changed the title Type-infer local functions infer local function return types Aug 4, 2016

@jmesserly jmesserly self-assigned this Aug 4, 2016

@jmesserly

This comment has been minimized.

Copy link
Contributor

commented Aug 4, 2016

@jmesserly jmesserly closed this in 1bb6da7 Aug 5, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.