[#97678] [Ruby master Feature#16752] :private param for const_set — bughitgithub@...
Issue #16752 has been reported by bughit (bug hit).
5 messages
2020/04/02
[ruby-core:98002] [Ruby master Bug#16797] Array#flatten not checking `respond_to? :to_ary`
From:
UlyssesZhan@...
Date:
2020-04-21 10:37:27 UTC
List:
ruby-core #98002
Issue #16797 has been updated by UlyssesZhan (有丘 詹). nobu (Nobuyoshi Nakada) wrote in #note-1: > Read the error message. > > ``` > -:4:in `flatten': can't convert Object to Array (Object#to_ary gives Object) (TypeError) > ``` Read what I wrote: > It should check whether an object responds to to_ary before trying to convert it into an array. I know it used `to_ary` method and got an unexpected result, but in fact calling `a.to_ary` itself is unexpected because `a.respond_to? :to_ary` is `false`. Detecting `NoMethodError` is a bit silly. ---------------------------------------- Bug #16797: Array#flatten not checking `respond_to? :to_ary` https://bugs.ruby-lang.org/issues/16797#change-85231 * Author: UlyssesZhan (有丘 詹) * Status: Rejected * Priority: Normal * ruby -v: ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux] * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN ---------------------------------------- ```ruby 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. -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>