-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Make the add_sig block nilable #371
base: main
Are you sure you want to change the base?
Conversation
Sig.new defines the block to be nilable and there are plenty of cases where you can add a sig without needing/wanting to use the block syntax.
What's the use-case where you would not need to supply the block? |
I'm using tapioca to generate a method with multiple signatures, I have one signature that takes a block and is a void otherwise it returns an enumerator Since tapioca doesn't return the method here, the only way I can access it to add the sigs is to use the block on within the block, I would like to just do:
but since the block is required I can't do that, I gotta do:
Though of course, I've now realized that I can do:
which gets me what I want, but I don't see why the block should be required on the add_sig call |
@@ -581,7 +581,7 @@ def add_block_param(name) | |||
is_final: T::Boolean, | |||
type_params: T::Array[String], | |||
checked: T.nilable(Symbol), | |||
block: T.proc.params(node: Sig).void, | |||
block: T.nilable(T.proc.params(node: Sig).void), |
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.
Do you mind adding a test for this under https://github.com/Shopify/rbi/blob/main/test/rbi/model_test.rb#L209 please? 🙏
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.
Sorry for the delay here, test added.
Sig.new defines the block to be nilable and there are plenty of cases where you can add a sig without needing/wanting to use the block syntax.