[ruby-core:118015] [Ruby master Bug#20510] File.open mode argument inconsistency

Issue #20510 has been reported by akr (Akira Tanaka). ---------------------------------------- Bug #20510: File.open mode argument inconsistency https://bugs.ruby-lang.org/issues/20510 * Author: akr (Akira Tanaka) * Status: Open * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- I found that `File.new(1, mode: File::WRONLY, path: "foo")` succeeds but `File.new(1, File::WRONLY, path: "foo")` fails. It is inconsistent. I think they should both succeed. ``` % ./ruby -e 'p File.new(1, mode: File::WRONLY, path: "foo")' #<File:foo> % ./ruby -e 'p File.new(1, File::WRONLY, path: "foo")' -e:1:in 'File#initialize': no implicit conversion of Integer into String (TypeError) p File.new(1, File::WRONLY, path: "foo") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ from -e:1:in 'IO.new' from -e:1:in '<main>' % ./ruby -v ruby 3.4.0dev (2024-05-25T02:25:56Z tempfile-create-io 99463a8400) [x86_64-linux] ``` -- https://bugs.ruby-lang.org/

Issue #20510 has been updated by nobu (Nobuyoshi Nakada). `File.new(1, File::WRONLY)` also succeeds. https://github.com/nobu/ruby/tree/File.new-arity-check ---------------------------------------- Bug #20510: File.open mode argument inconsistency https://bugs.ruby-lang.org/issues/20510#change-108435 * Author: akr (Akira Tanaka) * Status: Open * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- I found that `File.new(1, mode: File::WRONLY, path: "foo")` succeeds but `File.new(1, File::WRONLY, path: "foo")` fails. It is inconsistent. I think they should both succeed. ``` % ./ruby -e 'p File.new(1, mode: File::WRONLY, path: "foo")' #<File:foo> % ./ruby -e 'p File.new(1, File::WRONLY, path: "foo")' -e:1:in 'File#initialize': no implicit conversion of Integer into String (TypeError) p File.new(1, File::WRONLY, path: "foo") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ from -e:1:in 'IO.new' from -e:1:in '<main>' % ./ruby -v ruby 3.4.0dev (2024-05-25T02:25:56Z tempfile-create-io 99463a8400) [x86_64-linux] ``` -- https://bugs.ruby-lang.org/
participants (2)
-
akr (Akira Tanaka)
-
nobu (Nobuyoshi Nakada)