[Feature request] Introduce constant type
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 2.2k
- Forks
- 256
- Avg merge
- 6d 17h
- Merged PRs (30d)
- 37
Description
When I've recently opened PR to add signatures of the Parallel gem on the ruby/gem_rbs_collection repository, I encounter the following difficulty:
# Ruby code
items = [1, 2, 3]
Parallel.all?(-> { items.pop || Parallel::Stop }) { |item| item.size == 1 }
# RBS (short version)
module Parallel
Stop: Object
# `T | Stop` should be better than `T | untyped`.
def self.all?: [T] (Enumerable[T] | (^() -> T | untyped) array) { (T) -> boolish } -> bool
end
As you see above, we now cannot use Parallel::Stop as a type.
Supporting such a type signature might be useful, but what do you think?
This proposal is thanks to @pocke. Please refer to https://github.com/ruby/gem_rbs_collection/pull/21#discussion_r587286192 for details.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the issue's Parallel example and the linked gem_rbs_collection discussion to understand how a constant such as Parallel::Stop is currently parsed and represented. Determine the design needed for using that constant as a type, then add coverage for the example and verify that the signature can use Parallel::Stop instead of untyped.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100