From c7fd1c0f1453422aaefc63352e096339eba756c3 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Thu, 21 May 2026 17:48:20 +0900 Subject: [PATCH] Split parameter-driven return types into overloads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Several methods have a boolean-ish argument that determines the return type. Express each with literal `true`/`false` overloads instead of a single signature with a loose union return: - `Kernel#BigDecimal`: `exception: false` returns `nil` on a conversion failure, so `(?exception: true) -> BigDecimal` / `(exception: false) -> BigDecimal?`. - `Thread::Queue#pop`: `non_block: true` raises `ThreadError` when the queue is empty, so it never returns `nil` — `(true) -> E` / `(?false, ?timeout:) -> E?`. --- core/thread.rbs | 3 ++- stdlib/bigdecimal/0/big_decimal.rbs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/core/thread.rbs b/core/thread.rbs index b3e7d78c1..7bbaac8ef 100644 --- a/core/thread.rbs +++ b/core/thread.rbs @@ -1719,7 +1719,8 @@ class Thread::Queue[E = untyped] < Object # If `timeout` seconds have passed and no data is available `nil` is returned. # If `timeout` is `0` it returns immediately. # - def pop: (?boolish non_block, ?timeout: _ToF?) -> E? + def pop: (?false non_block, ?timeout: _ToF?) -> E? + | (true non_block) -> E #