Perl almost does this. Various CPAN packages have different "use" lines where they can declare themselves to be written in a particular version. These can all live together on an interpreter recent enough to know all the dialects. This is at the module level, rather than the function level though.
I'm imagining something like `foo@v2.3.1(x)`. Of course, `foo(x)` would still work, but it would probably just choose the top version, like how things generally work today. Integrate with signed VCS and call it a day.