From 51d27db14c0522d82ba9f4eeb04a8a48a39e064d Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Thu, 21 May 2026 15:59:15 +0900 Subject: [PATCH] Replace deterministic `untyped` return types with concrete types Several methods were typed `-> untyped` even though their return value is determined by the implementation. Give them concrete types: - `StringIO#putc`, `Zlib::GzipWriter#putc` -> `Numeric | String` (returns the argument) - `Zlib::GzipFile#sync=` -> `boolish` (setter returns the argument) - `MonitorMixin::ConditionVariable#wait_for_cond` / `#wait` -> `bool` - `MonitorMixin::ConditionVariable#wait_until` / `#wait_while` -> `nil` (loop expression) - `ERB#run` -> `nil`, `ERB#initialize` -> `void` - `ERB#def_method`, `ERB::DefMethod.def_erb_method` -> `Symbol` --- stdlib/erb/0/erb.rbs | 8 ++++---- stdlib/monitor/0/monitor.rbs | 8 ++++---- stdlib/stringio/0/stringio.rbs | 2 +- stdlib/zlib/0/gzip_file.rbs | 2 +- stdlib/zlib/0/gzip_writer.rbs | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/stdlib/erb/0/erb.rbs b/stdlib/erb/0/erb.rbs index 7d49f11a24..befb0d3da6 100644 --- a/stdlib/erb/0/erb.rbs +++ b/stdlib/erb/0/erb.rbs @@ -619,7 +619,7 @@ class ERB # It's good practice to choose a variable name that begins with an underscore: # '_'. # - def initialize: (String, ?eoutvar: String, ?trim_mode: Integer | String | NilClass) -> untyped + def initialize: (String, ?eoutvar: String, ?trim_mode: Integer | String | NilClass) -> void # # Returns the Ruby code that, when executed, generates the result; @@ -702,7 +702,7 @@ class ERB # Like #result, but prints the result string (instead of returning it); # returns `nil`. # - def run: (?Binding) -> untyped + def run: (?Binding) -> nil # diff --git a/stdlib/monitor/0/monitor.rbs b/stdlib/monitor/0/monitor.rbs index f4bca5a0e0..031775d632 100644 --- a/stdlib/monitor/0/monitor.rbs +++ b/stdlib/monitor/0/monitor.rbs @@ -111,7 +111,7 @@ class Monitor # - wait_for_cond(p1, p2) # --> # - def wait_for_cond: (::MonitorMixin::ConditionVariable, Numeric? timeout) -> untyped + def wait_for_cond: (::MonitorMixin::ConditionVariable, Numeric? timeout) -> bool end # @@ -334,7 +334,7 @@ class MonitorMixin::ConditionVariable # If `timeout` is given, this method returns after `timeout` seconds passed, # even if no other thread doesn't signal. # - def wait: (?Numeric? timeout) -> untyped + def wait: (?Numeric? timeout) -> bool # # Calls wait repeatedly until the given block yields a truthy value. # - def wait_until: () { () -> boolish } -> untyped + def wait_until: () { () -> boolish } -> nil # # Calls wait repeatedly while the given block yields a truthy value. # - def wait_while: () { () -> boolish } -> untyped + def wait_while: () { () -> boolish } -> nil private diff --git a/stdlib/stringio/0/stringio.rbs b/stdlib/stringio/0/stringio.rbs index f7a8ffaf05..da09cf4ed8 100644 --- a/stdlib/stringio/0/stringio.rbs +++ b/stdlib/stringio/0/stringio.rbs @@ -1271,7 +1271,7 @@ class StringIO # --> # See IO#putc. # - def putc: (Numeric | String arg0) -> untyped + def putc: (Numeric | String arg0) -> (Numeric | String) def puts: (*untyped arg0) -> nil diff --git a/stdlib/zlib/0/gzip_file.rbs b/stdlib/zlib/0/gzip_file.rbs index 5da64df3db..66b79e4834 100644 --- a/stdlib/zlib/0/gzip_file.rbs +++ b/stdlib/zlib/0/gzip_file.rbs @@ -143,7 +143,7 @@ module Zlib # `flush` method. While `sync` mode is `true`, the compression ratio decreases # sharply. # - def sync=: (boolish) -> untyped + def sync=: (boolish) -> boolish # # Same as IO. # - def putc: (Numeric | String arg0) -> untyped + def putc: (Numeric | String arg0) -> (Numeric | String) #