Skip to content

Skip bot type in typecheck to fix false errors on return/next#389

Merged
mame merged 1 commit intoruby:masterfrom
mame:fix-bot-type-return-typecheck
Feb 25, 2026
Merged

Skip bot type in typecheck to fix false errors on return/next#389
mame merged 1 commit intoruby:masterfrom
mame:fix-bot-type-return-typecheck

Conversation

@mame
Copy link
Member

@mame mame commented Feb 25, 2026

When a method body ends with a return (or a branch contains one), the implicit return value of the body includes bot (bottom type). Because bot is a subtype of all types, typecheck should not reject it. Previously each typecheck implementation iterated over every type in the vertex including bot, which caused spurious diagnostics like "expected: bool; actual: bot".

Add next if ty.is_a?(Type::Bot) to all leaf typecheck methods in sig_type.rb so that bot is uniformly skipped during type checking.

Fixes #377

When a method body ends with a `return` (or a branch contains one),
the implicit return value of the body includes `bot` (bottom type).
Because `bot` is a subtype of all types, typecheck should not reject
it. Previously each typecheck implementation iterated over every type
in the vertex including `bot`, which caused spurious diagnostics like
"expected: bool; actual: bot".

Add `next if ty.is_a?(Type::Bot)` to all leaf typecheck methods in
sig_type.rb so that `bot` is uniformly skipped during type checking.

Fixes ruby#377
@mame mame enabled auto-merge (rebase) February 25, 2026 05:00
@mame mame merged commit 8d681f2 into ruby:master Feb 25, 2026
7 checks passed
@mame mame deleted the fix-bot-type-return-typecheck branch February 25, 2026 05:02
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.

Unexpected errors when specifying method signatures in RBS and returning values with return

1 participant