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

Type inference (synthesize) for lambdas #451

Open
hugomg opened this issue Aug 7, 2021 · 0 comments
Open

Type inference (synthesize) for lambdas #451

hugomg opened this issue Aug 7, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@hugomg
Copy link
Member

hugomg commented Aug 7, 2021

It would be nice if we could infer the type of a lambda, by putting type annotations on the arguments:

-- infer type "integer -> integer"
local f = function(x: integer) return x+1 end

However, we still want to allow the programmer to omit the type annotations for the arguments, if the function is used in a context where the type is known:

foreach(xs, function(x)
    dosomething(x)
end)

One thing that I don't know how we should handle in the code, is if a lambda is used in a context of type any. If the type annotations are present, it should be possible to insert the type coercion. However, if the annotations are not present, then I guess it would have to be a type error.

local f: any = function(x) end
@hugomg hugomg added the enhancement New feature or request label Aug 7, 2021
@hugomg hugomg self-assigned this Aug 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant