Actions
Bug #19721
closedIO#timeout= can be called without required argument
Bug #19721:
IO#timeout= can be called without required argument
Description
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:
Updated by ufuk (Ufuk Kayserilioglu) over 3 years ago
I believe the syntax f.timeout=() is not calling the timeout= method with no parameters, but instead it is assigning () to f.timeout attribute. Since () in Ruby evaluates to nil (because it is an empty subexpression), in essence, that line should be equivalent to f.timeout = nil. That's why you get the nil value.
You can check that this expression gets turned into an assigment by looking at the AST generated from f.timeout=() on https://ruby-syntax-tree.github.io/:
Updated by jeremyevans0 (Jeremy Evans) over 3 years ago
Updated by andrykonchin (Andrew Konchin) over 3 years ago
Ah, I see. Thank you.
Actions