Skip to content

Infer calls based on their return types (maybe) #1137

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

Open
dcodeIO opened this issue Mar 1, 2020 · 2 comments
Open

Infer calls based on their return types (maybe) #1137

dcodeIO opened this issue Mar 1, 2020 · 2 comments

Comments

@dcodeIO
Copy link
Member

dcodeIO commented Mar 1, 2020

Edit: While working on #1129 I stumbled upon the following pattern that cannot be inferred yet because we don't yet attempt to recognize return types:

function foo(a: Set<i32> = new Set()) { ... }
function makeSet<T>(): Set<T> { ... }
foo(makeSet()); // expected 1 type argument, but got 0

Pinning here so we don't forget.

@dcodeIO dcodeIO added the bug label Mar 1, 2020
@dcodeIO dcodeIO mentioned this issue Mar 1, 2020
8 tasks
@dcodeIO
Copy link
Member Author

dcodeIO commented Mar 2, 2020

Turns out that the first sample

function foo(a: Set<i32> = new Set()) // expected 1 type argument, but got 0

(in the original post) came from a diagnostic I fixed now that should be suppressed but otherwise works, while the second is not implemented yet (requires inferring based on return type).

@dcodeIO dcodeIO added enhancement and removed bug labels Mar 2, 2020
@dcodeIO dcodeIO changed the title Investigate contextual type propagation on initializers Investigate inferring calls based on their return types Mar 2, 2020
@dcodeIO dcodeIO changed the title Investigate inferring calls based on their return types Infer calls based on their return types (maybe) May 27, 2020
@MaxGraey
Copy link
Member

Up

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

No branches or pull requests

2 participants