Skip to content

Commit 5d89db6

Browse files
committed
Autocorrect and replace #nil? with Primitive.nil?
1 parent ae7eda6 commit 5d89db6

File tree

9 files changed

+16
-16
lines changed

9 files changed

+16
-16
lines changed

src/main/ruby/truffleruby/core/enumerator.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class Enumerator
7070
end
7171

7272
def inspect
73-
return "#<#{self.class}: uninitialized>" if @object.nil? && @iter.nil?
73+
return "#<#{self.class}: uninitialized>" if Primitive.nil?(@object) && Primitive.nil?(@iter)
7474

7575
args = @kwargs.empty? ? @args : [*@args, @kwargs]
7676
args = args.empty? ? '' : "(#{args.map(&:inspect).join(', ')})"
@@ -222,7 +222,7 @@ def self.produce(initial = nil)
222222
# Taken from https://github.com/zverok/enumerator_generate
223223
raise ArgumentError, 'No block given' unless block_given?
224224
Enumerator.new(Float::INFINITY) do |y|
225-
val = initial == nil ? yield() : initial
225+
val = Primitive.nil?(initial) ? yield() : initial
226226

227227
loop do
228228
y << val

src/main/ruby/truffleruby/core/io.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ def binmode?
10141014

10151015
# Used to find out if there is buffered data available.
10161016
private def buffer_empty?
1017-
@ibuffer.nil? or @ibuffer.empty?
1017+
Primitive.nil?(@ibuffer) or @ibuffer.empty?
10181018
end
10191019

10201020
def close_on_exec=(value)

src/main/ruby/truffleruby/core/kernel.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ def caller_locations(omit = 1, length = undefined)
761761
module_function :caller_locations
762762

763763
def at_exit(&block)
764-
raise ArgumentError, 'called without a block' if block.nil?
764+
raise ArgumentError, 'called without a block' if Primitive.nil?(block)
765765
Truffle::KernelOperations.at_exit false, &block
766766
end
767767
module_function :at_exit

src/main/ruby/truffleruby/core/process.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -683,19 +683,19 @@ def coredump?
683683
end
684684

685685
def exited?
686-
@exitstatus != nil
686+
!Primitive.nil?(@exitstatus)
687687
end
688688

689689
def pid
690690
@pid
691691
end
692692

693693
def signaled?
694-
@termsig != nil
694+
!Primitive.nil?(@termsig)
695695
end
696696

697697
def stopped?
698-
@stopsig != nil
698+
!Primitive.nil?(@stopsig)
699699
end
700700

701701
def success?

src/main/ruby/truffleruby/core/string.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def strip
290290
def strip!
291291
right = rstrip! # Process rstrip! first because it must perform an encoding compatibility check that lstrip! does not.
292292
left = lstrip!
293-
left.nil? && right.nil? ? nil : self
293+
Primitive.nil?(left) && Primitive.nil?(right) ? nil : self
294294
end
295295

296296
def succ

src/main/ruby/truffleruby/core/time.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def localtime(offset = nil)
179179
# the only cases when #localtime is allowed for a frozen time -
180180
# - to covert from UTC to UTC
181181
# - to convert from local time to the same local time
182-
if frozen? && !(utc? && to_utc || !utc? && offset.nil?)
182+
if frozen? && !(utc? && to_utc || !utc? && Primitive.nil?(offset))
183183
raise FrozenError, "can't modify frozen Time: #{self}"
184184
end
185185

src/main/ruby/truffleruby/core/truffle/complex_operations.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ def self.convert_not_real_arguments(real, imag, exception)
2020

2121
if Primitive.object_kind_of?(real, String)
2222
real = String::Complexifier.new(real).strict_convert(exception)
23-
return nil if real.nil?
23+
return nil if Primitive.nil?(real)
2424
end
2525

2626
if Primitive.object_kind_of?(imag, String)
2727
imag = String::Complexifier.new(imag).strict_convert(exception)
28-
return nil if imag.nil?
28+
return nil if Primitive.nil?(imag)
2929
end
3030

3131
if Primitive.object_kind_of?(real, Complex) && !Primitive.object_kind_of?(real.imag, Float) && real.imag == 0

src/main/ruby/truffleruby/core/truffle/process_operations.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ def parse_options(options)
309309

310310
def redirect(child_fd, parent_fd)
311311
map = (@options[:redirect_fd] ||= [])
312-
if parent_fd.nil?
312+
if Primitive.nil?(parent_fd)
313313
fds_to_close = (@options[:fds_to_close] ||= [])
314314
fds_to_close << child_fd
315315
elsif child_fd == parent_fd

src/main/ruby/truffleruby/core/truffle/regexp_operations.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ def self.match_args_to_string(re, str, enc, from, to, at_start, start, suffix)
122122
end
123123

124124
def self.results_match?(md1, md2)
125-
if md1 == nil
126-
md2 == nil
127-
elsif md2 == nil
125+
if Primitive.nil?(md1)
126+
Primitive.nil?(md2)
127+
elsif Primitive.nil?(md2)
128128
false
129129
elsif Primitive.object_kind_of?(md1, Exception)
130130
md1.class == md2.class
@@ -144,7 +144,7 @@ def self.results_match?(md1, md2)
144144
end
145145

146146
def self.print_match_data(md)
147-
if md == nil
147+
if Primitive.nil?(md)
148148
$stderr.puts ' NO MATCH'
149149
elsif Primitive.object_kind_of?(md, Exception)
150150
$stderr.puts " EXCEPTION - #{md}"

0 commit comments

Comments
 (0)