Update Array#2987
Conversation
786a245 to
31a4a54
Compare
| alias any? all? | ||
| def any?: () -> bool | ||
| | (_Pattern[E] pattern) -> bool | ||
| | () { (E element) -> boolish } -> bool |
There was a problem hiding this comment.
This was probably originally aliased because they share the same signature? but they shouldn't have been
| # | ||
| alias any? all? | ||
| def any?: () -> bool | ||
| | (_Pattern[E] pattern) -> bool |
There was a problem hiding this comment.
TODO: Use RBS::Ops:_Matches
| # Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying). | ||
| # | ||
| def include?: (top object) -> bool | ||
| def include?: (top object) -> bool # TODO: E: _Equals |
There was a problem hiding this comment.
Should this be top or untyped? And should other places be using top?
| | (int n) -> ::Array[E] | ||
| | (int n) { (E a, E b) -> ::Integer? } -> ::Array[E] | ||
| def max: %a{implicitly-returns-nil} () ?{ (E a, E b) -> Comparable::_CompareToZero? } -> E # TODO: where `E: Comparable::_WithSpaceshipOperator` | ||
| | (int count) ?{ (E a, E b) -> Comparable::_CompareToZero? } -> Array[E] # TODO: i dont think these shoudl have `?` in _CompareToZero. But it would make signatures nicer? |
There was a problem hiding this comment.
TODO: Should we have ? here in the signature? Actually having it will always cause an exception, but most <=> have nil in their return type.
| @@ -3292,7 +3302,7 @@ class Array[unchecked out E] < Object | |||
| # Related: see [Methods for Deleting](rdoc-ref:Array@Methods+for+Deleting). | |||
| # | |||
| def shift: %a{implicitly-returns-nil} () -> E | |||
There was a problem hiding this comment.
It feels weird to have this be an implicitly-returns-nil
| # | ||
| def sum: (?untyped init) -> untyped | ||
| | (?untyped init) { (E e) -> untyped } -> untyped | ||
| def sum: (?untyped init) ?{ (E e) -> untyped } -> untyped # This would be usable if we had `where E < Complex`, etc |
There was a problem hiding this comment.
I wish there was a better way to solve sum
| def rand: (Integer max) -> Integer | ||
| end | ||
|
|
||
| interface Array::_Pattern[T] |
There was a problem hiding this comment.
TODO: deprecate this and just use RBS::Ops when needed
1eef064 to
0fa718e
Compare
| def bsearch: () -> ::Enumerator[E, E?] | ||
| | () { (E) -> (true | false) } -> E? | ||
| | () { (E) -> ::Integer } -> E? | ||
| def bsearch: () { (E element) -> (Numeric | bool?) } -> E? |
There was a problem hiding this comment.
I'm not sure if this works for actual type checkers, but these definitions are not equivalent.
Returning both true | false and Integer from a block is not allowed to bsearch, I think.
There was a problem hiding this comment.
[…].bsearch { it.positive? and it } # false | Integer| # | ||
| def sort!: () -> self | ||
| | () { (E a, E b) -> ::Integer } -> self | ||
| def sort!: () ?{ (E a, E b) -> Comparable::_CompareToZero } -> Array[E] |
There was a problem hiding this comment.
Does it return self instead of Array[E]?
cc52661 to
4691c6d
Compare
This PR completely updates
Array's signatures, and rewrites the test harness to work with it.Note that there's a handful of
TODOs strewn about in:Array.[])