Skip to content

Fix RBS syntax error#837

Open
hakanensari wants to merge 1 commit intohttprb:mainfrom
hakanensari:fix-rbs-void-union-syntax
Open

Fix RBS syntax error#837
hakanensari wants to merge 1 commit intohttprb:mainfrom
hakanensari:fix-rbs-void-union-syntax

Conversation

@hakanensari
Copy link
Contributor

@hakanensari hakanensari commented Mar 19, 2026

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.

Copilot AI review requested due to automatic review settings March 19, 2026 21:49
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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) with def rewind: () -> Integer in HTTP::FormData::Readable.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

sig/http.rbs Outdated
Comment on lines +1274 to +1275
# Rewinds the IO to the beginning
def rewind: () -> (Integer | void)
def rewind: () -> Integer
Copy link

Copilot AI Mar 19, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

@hakanensari hakanensari force-pushed the fix-rbs-void-union-syntax branch from 018980b to 6fda6fe Compare March 19, 2026 22:02
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.
@hakanensari hakanensari force-pushed the fix-rbs-void-union-syntax branch from 6fda6fe to b5301ca Compare March 19, 2026 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants