From ec1f9860b1865fd5281ddcf9911a6fb7cf8fff35 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Thu, 4 Dec 2025 18:20:35 +0900 Subject: [PATCH] mrblib: add parentheses to method calls with used return values added parentheses to all `to_enum` and `super` calls where the return value is used (returned, assigned, or passed to another method). this makes the code style consistent with the guideline that method calls should use parentheses when their return values are consumed. changes: - return to_enum :symbol -> return to_enum(:symbol) - return to_enum :symbol, arg -> return to_enum(:symbol, arg) - super message, name -> super(message, name) affected files: 10error.rb, array.rb, enum.rb, hash.rb, kernel.rb, numeric.rb, range.rb Co-authored-by: Claude --- mrblib/10error.rb | 2 +- mrblib/array.rb | 6 +++--- mrblib/enum.rb | 12 ++++++------ mrblib/hash.rb | 14 +++++++------- mrblib/kernel.rb | 2 +- mrblib/numeric.rb | 2 +- mrblib/range.rb | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/mrblib/10error.rb b/mrblib/10error.rb index 98d4d2a76..734e48b12 100644 --- a/mrblib/10error.rb +++ b/mrblib/10error.rb @@ -14,7 +14,7 @@ class NoMethodError < NameError def initialize(message=nil, name=nil, args=nil) @args = args - super message, name + super(message, name) end end diff --git a/mrblib/array.rb b/mrblib/array.rb index 937b5d1be..8b04b680e 100644 --- a/mrblib/array.rb +++ b/mrblib/array.rb @@ -13,7 +13,7 @@ class Array # # ISO 15.2.12.5.10 def each(&block) - return to_enum :each unless block + return to_enum(:each) unless block idx = 0 while idx < length @@ -33,7 +33,7 @@ class Array # # ISO 15.2.12.5.11 def each_index(&block) - return to_enum :each_index unless block + return to_enum(:each_index) unless block idx = 0 while idx < length @@ -54,7 +54,7 @@ class Array # # ISO 15.2.12.5.7 def collect!(&block) - return to_enum :collect! unless block + return to_enum(:collect!) unless block idx = 0 len = size diff --git a/mrblib/enum.rb b/mrblib/enum.rb index e4f8973dd..956c8644f 100644 --- a/mrblib/enum.rb +++ b/mrblib/enum.rb @@ -57,7 +57,7 @@ module Enumerable # # ISO 15.3.2.2.3 def collect(&block) - return to_enum :collect unless block + return to_enum(:collect) unless block ary = [] self.each{|*val| ary.push(block.call(*val))} @@ -73,7 +73,7 @@ module Enumerable # # ISO 15.3.2.2.4 def detect(ifnone=nil, &block) - return to_enum :detect, ifnone unless block + return to_enum(:detect, ifnone) unless block self.each{|*val| if block.call(*val) @@ -91,7 +91,7 @@ module Enumerable # # ISO 15.3.2.2.5 def each_with_index(&block) - return to_enum :each_with_index unless block + return to_enum(:each_with_index) unless block i = 0 self.each{|*val| @@ -129,7 +129,7 @@ module Enumerable # # ISO 15.3.2.2.8 def find_all(&block) - return to_enum :find_all unless block + return to_enum(:find_all) unless block ary = [] self.each{|*val| @@ -284,7 +284,7 @@ module Enumerable # # ISO 15.3.2.2.16 def partition(&block) - return to_enum :partition unless block + return to_enum(:partition) unless block ary_T = [] ary_F = [] @@ -306,7 +306,7 @@ module Enumerable # # ISO 15.3.2.2.17 def reject(&block) - return to_enum :reject unless block + return to_enum(:reject) unless block ary = [] self.each{|*val| diff --git a/mrblib/hash.rb b/mrblib/hash.rb index bee4abf23..1533b1cd7 100644 --- a/mrblib/hash.rb +++ b/mrblib/hash.rb @@ -52,7 +52,7 @@ class Hash # # ISO 15.2.13.4.9 def each(&block) - return to_enum :each unless block + return to_enum(:each) unless block keys = self.keys vals = self.values @@ -85,7 +85,7 @@ class Hash # # ISO 15.2.13.4.10 def each_key(&block) - return to_enum :each_key unless block + return to_enum(:each_key) unless block self.keys.each{|k| block.call(k)} self @@ -110,7 +110,7 @@ class Hash # # ISO 15.2.13.4.11 def each_value(&block) - return to_enum :each_value unless block + return to_enum(:each_value) unless block self.values.each{|v| block.call(v)} self @@ -165,7 +165,7 @@ class Hash # 1.8/1.9 Hash#reject! returns Hash; ISO says nothing. # def reject!(&block) - return to_enum :reject! unless block + return to_enum(:reject!) unless block keys = [] self.each{|k,v| @@ -196,7 +196,7 @@ class Hash # 1.8/1.9 Hash#reject returns Hash; ISO says nothing. # def reject(&block) - return to_enum :reject unless block + return to_enum(:reject) unless block h = {} self.each{|k,v| @@ -218,7 +218,7 @@ class Hash # 1.9 Hash#select! returns Hash; ISO says nothing. # def select!(&block) - return to_enum :select! unless block + return to_enum(:select!) unless block keys = [] self.each{|k,v| @@ -249,7 +249,7 @@ class Hash # 1.9 Hash#select returns Hash; ISO says nothing # def select(&block) - return to_enum :select unless block + return to_enum(:select) unless block h = {} self.each{|k,v| diff --git a/mrblib/kernel.rb b/mrblib/kernel.rb index 510c89e17..52c3e4931 100644 --- a/mrblib/kernel.rb +++ b/mrblib/kernel.rb @@ -25,7 +25,7 @@ module Kernel # # ISO 15.3.1.3.29 private def loop(&block) - return to_enum :loop unless block + return to_enum(:loop) unless block while true yield diff --git a/mrblib/numeric.rb b/mrblib/numeric.rb index 004af69b9..10e6f55ad 100644 --- a/mrblib/numeric.rb +++ b/mrblib/numeric.rb @@ -70,7 +70,7 @@ class Integer # # ISO 15.2.8.3.22 def times(&block) - return to_enum :times unless block + return to_enum(:times) unless block i = 0 while i < self diff --git a/mrblib/range.rb b/mrblib/range.rb index 0fb0e8cbd..96e2ebf24 100644 --- a/mrblib/range.rb +++ b/mrblib/range.rb @@ -15,7 +15,7 @@ class Range # # ISO 15.2.14.4.4 def each(&block) - return to_enum :each unless block + return to_enum(:each) unless block val = self.begin last = self.end