Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

parameter type inference for anonymous functions in assignments #7058

Open
fwgreen opened this issue May 6, 2017 · 6 comments
Open

parameter type inference for anonymous functions in assignments #7058

fwgreen opened this issue May 6, 2017 · 6 comments

Comments

@fwgreen
Copy link

fwgreen commented May 6, 2017

Here is one possible use case

shared Object bar(Request req, Response res) => "Hello";
shared Object baz(Request req, Response res) => "World ";
// ...
//vs
shared alias Route => Object(Request, Response);
shared Route bar = (req, res) => "Hello";
shared Route baz = (req, res) => "World";
// ...
@gavinking gavinking self-assigned this May 8, 2017
@gavinking gavinking added this to the 1.4 milestone May 8, 2017
@gavinking gavinking changed the title Consider inferring the parameter type of lambdas with explicit return types. parameter type inference for anonymous functions in assignments Apr 17, 2018
@gavinking gavinking self-assigned this Apr 17, 2018
@gavinking
Copy link
Contributor

Given that I'm doing work in this area now, as a consequence of #6615, time is probably ripe to make a start on this issue.

@gavinking
Copy link
Contributor

gavinking commented Apr 18, 2018

This is now basically done, on the 6615 branch.

@fwgreen
Copy link
Author

fwgreen commented Apr 18, 2018

I just tried it, and it doesn't appear to be working:

error: parameter is not declared explicitly, and its type cannot be inferred:

@gavinking
Copy link
Contributor

@fwgreen I just tried it with this code:

shared interface Request {}
shared interface Response {}

shared alias Route => Object(Request, Response);
shared Route bar = (req, res) => "Hello";
shared Route baz = (req, res) => "World";

and it worked.

Are you sure you're on the right branch?

@fwgreen
Copy link
Author

fwgreen commented Apr 18, 2018

@gavinking I cloned it again and this time it works! Thanks!

gavinking added a commit that referenced this issue Apr 18, 2018
gavinking added a commit that referenced this issue Apr 18, 2018
- add pipeline operator |> #6615
- add fish operator >|> operator for #3229
- parameter type inference for anonymous functions in assignments #7058
- parameter type inference for immediately-invoked anonymous functions
@gavinking
Copy link
Contributor

I've merged this work to master. Still need to define it in the spec.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants