-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Treat single splats with same restriction as equivalent #12584
Treat single splats with same restriction as equivalent #12584
Conversation
def old_min_args_size | ||
if splat_index = self.def.splat_index | ||
args = self.def.args | ||
unless args[splat_index].name.empty? | ||
default_value_index = args.index(&.default_value) | ||
min_size = default_value_index || args.size | ||
min_size -= 1 unless default_value_index.try(&.< splat_index) | ||
return min_size | ||
end | ||
end | ||
self.min_size | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implementation looks very similar to Def#min_max_args_sizes
. Could we just use that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First the max size is unaffected, second we already know that -Dpreview_overload_order
is not in effect at this point. If we check for that flag in min_max_args_sizes
itself there could be a performance impact and some other uses of the method also become inconsistent (e.g. too-few-argunents errors).
There might be a better way to derive the old min size from the new min size. I don't know if it would end up doing the same amount of work though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm okay with leaving it like that. But maybe add a comment about this to the code?
Fixes #12579 by ensuring the old behavior of
Crystal::Def#min_max_args_sizes
is used during overload ordering. (The new one is still used in other places like error reporting.)Has no effect on
-Dpreview_overload_order
.