Project

General

Profile

Actions

Bug #16797

closed

Array#flatten not checking `respond_to? :to_ary`

Added by UlyssesZhan (Ulysses Zhan) over 4 years ago. Updated over 4 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]
[ruby-core:97937]

Description

def (a = Object.new).method_missing(...)
  Object.new
end
[a].flatten # TypeError

It should check whether an object responds to to_ary before trying to convert it into an array.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0