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

Support rest arguments #284

Merged
merged 1 commit into from
Dec 20, 2024
Merged

Support rest arguments #284

merged 1 commit into from
Dec 20, 2024

Conversation

alpaca-tc
Copy link
Contributor

  • Initialized rest arguments in method definitions as array.
  • Updated method call to add edges to array types.

Further improvements may be possible.

@alpaca-tc alpaca-tc marked this pull request as draft December 18, 2024 14:45
@alpaca-tc alpaca-tc force-pushed the support-splat-array branch 2 times, most recently from bdafbc1 to c9511a4 Compare December 18, 2024 14:59
Comment on lines +527 to +528
@f_args.rest_positionals.each_type do |ty|
if ty.is_a?(Type::Instance) && ty.mod == genv.mod_ary && ty.args[0]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed some duplicate code, which feels a bit dirty, but I decided to go ahead and open the PR since cleaning it up won't matter if the approach itself is flawed.
Do you have any suggestions for making this part of the code more DRY? The simplest solution would be to define a private method to consolidate the logic, but it doesn't feel like the optimal approach...

@alpaca-tc alpaca-tc marked this pull request as ready for review December 18, 2024 15:02
- Initialized rest arguments in method definitions as array.
- Updated method call to add edges to array types.

Further improvements may be possible.
@mame mame force-pushed the support-splat-array branch from c9511a4 to 588aec8 Compare December 20, 2024 13:40
@mame
Copy link
Member

mame commented Dec 20, 2024

Thank you! It looks good to me. TBH, I am not sure if this design has any flaw or not. We can reconsider it if we actually use it and find any problem.

As for DRY, I have no strong opinion, but I think this PR is acceptable. The TypeProf source code is very difficult to understand, I guess it may be easier to understand if it is written plainly, even if it is a bit duplicated.

@mame mame merged commit 2e9ef02 into ruby:master Dec 20, 2024
6 checks passed
@alpaca-tc alpaca-tc deleted the support-splat-array branch December 25, 2024 04:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants