Project

General

Profile

Actions

Bug #20510

closed

File.open mode argument inconsistency

Added by akr (Akira Tanaka) 5 months ago. Updated 5 months ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:118015]

Description

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]
Actions

Also available in: Atom PDF

Like0
Like0Like0