You can do that. But as a language feature, inter-procedural inference creates problems for humans. There's no way for humans to see what type a function wants.
Language design seems to be converging on the idea that functions should have human-readable type signatures, but within functions, automatic inference can be used freely. In one direction, we have the "auto" inference mechanism of C and C++,
and the local inference of Go and Rust. In the other direction, we have TypeScript for JavaScript and Python's rather strange unchecked optional typing. All those changes move towards the center position.
(Then, of course, there are "lambdas", but that's another subject.)
You can do that. But as a language feature, inter-procedural inference creates problems for humans. There's no way for humans to see what type a function wants.
Language design seems to be converging on the idea that functions should have human-readable type signatures, but within functions, automatic inference can be used freely. In one direction, we have the "auto" inference mechanism of C and C++, and the local inference of Go and Rust. In the other direction, we have TypeScript for JavaScript and Python's rather strange unchecked optional typing. All those changes move towards the center position.
(Then, of course, there are "lambdas", but that's another subject.)