Conversation
There was a problem hiding this comment.
Pull request overview
Updates the RBS for HTTP::FormData::Readable#rewind to avoid an RBS 4.0 parser error caused by using void inside a union type, aligning the signature with Ruby’s IO#rewind/StringIO#rewind behavior.
Changes:
- Replace
def rewind: () -> (Integer | void)withdef rewind: () -> IntegerinHTTP::FormData::Readable.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
sig/http.rbs
Outdated
| # Rewinds the IO to the beginning | ||
| def rewind: () -> (Integer | void) | ||
| def rewind: () -> Integer |
There was a problem hiding this comment.
Readable#rewind now returns Integer, but @io is declared as StringIO | CompositeIO and CompositeIO#rewind is currently typed as () -> void later in this same RBS file. With Steep checking lib/ against sig/, this will likely produce a type mismatch for lib/http/form_data/readable.rb#rewind (it delegates to @io.rewind). Consider also updating CompositeIO#rewind’s signature to () -> Integer (it returns 0 in Ruby because the last expression is @index = 0), so the types are consistent and Steep can type-check the implementation.
There was a problem hiding this comment.
Good catch. Changed to void instead of Integer to stay consistent with CompositeIO#rewind. The integer return was, in any case, just a side effect of the implementation.
Steep and rbs parse pass either way.
018980b to
6fda6fe
Compare
The newly-released RBS 4.0 rejects void in union types at the parser level. The (Integer | void) return type on Readable#rewind now causes a hard parse error. Change to `void`, consistent with CompositeIO#rewind and the YARD @return annotation.
6fda6fe to
b5301ca
Compare
The newly-released RBS 4.0 rejects
voidin union types at the parser level. The(Integer | void)return type onReadable#rewindnow causes a hard parse error.Change to
void, consistent with CompositeIO#rewind and the YARD @return annotation.