From: "jeremyevans0 (Jeremy Evans) via ruby-core" Date: 2023-06-08T15:04:40+00:00 Subject: [ruby-core:113831] [Ruby master Bug#19721] IO#timeout= can be called without required argument Issue #19721 has been updated by jeremyevans0 (Jeremy Evans). Status changed from Open to Rejected All assignment methods called via `recv.method = ` are called with one argument. `()` is translated to `nil` by the compiler, because it is an expression that is evaluated to `nil`: ```ruby eval('()') # => nil ``` ---------------------------------------- Bug #19721: IO#timeout= can be called without required argument https://bugs.ruby-lang.org/issues/19721#change-103477 * Author: andrykonchin (Andrew Konchin) * Status: Rejected * Priority: Normal * ruby -v: 3.2.1 * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- ```ruby f = File.open("a.txt", "w") f.timeout=() # => nil ``` `IO#timeout=` requires an argument (or it's supposed to require it) but if it's called as a method it seems the check is skipped and missing argument is treated as `nil` value. If it's called with `#send` - then argument presence is checked: ```ruby f.send :"timeout=" # ...:in `timeout=': wrong number of arguments (given 0, expected 1) (ArgumentError) ``` -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/