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

Another type inference bug #469

Closed
zpdDG4gta8XKpMCd opened this issue Aug 16, 2014 · 2 comments
Closed

Another type inference bug #469

zpdDG4gta8XKpMCd opened this issue Aug 16, 2014 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@zpdDG4gta8XKpMCd
Copy link

function g<a, b, r>(f: (one: a, two: b) => r, one: a, two: b) {
    return f(one, two);
}
function f(text: string, index: number) { return text.substr(index); }
alert(g(f, 'hey', 1));  // <-- compiles and works
alert(g(f, 1, 'hey'));  // <-- a problem: compiles but crashes at runtime
// expected: compilation error, `f` expects a string and a number, not an empty type value
// actual: all arguments are resolved to empty type values which are not what the funciton `f` is designed to accept

at playground

@basarat
Copy link
Contributor

basarat commented Aug 18, 2014

@Aleksey-Bykov reason : #360

@RyanCavanaugh
Copy link
Member

Yep, same root cause.

@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants