Would it be possible to type narrow overloads after the fact? #8549
JanEricNitschke
started this conversation in
Ideas
Replies: 1 comment
-
I don't think this is feasible. It's unlikely that this would ever be implemented. See this comment for the reasoning. The technique you're using in |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a case where i have an overloaded function where the different return types largely overlap. So regardless of which overload is chosen there is a lot of work that can be performed on any of the return types.
The setup is basically like func/func2 in this:
func2 would allow me to reduce duplication, but does not type check because obviously the type checker does not remember that the narrowing of
stuff
depends on value. Meanwhile func3 typechecks but i have duplication.Is there any chance that something like this could be introduced or am i missing (some obvious?) issues that this would introduce (besides the possible enormous work that might have to be done)?
Playground link
Beta Was this translation helpful? Give feedback.
All reactions