From 0a0cc5a217b577dfadddfb250d5a91ca69978887 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Mon, 19 Nov 2018 10:40:07 +0900 Subject: Check method existence for Enumerators; fix #3920 The issue #3920 was fixed but the fundamental flaw of lack of stack depth check along with fibers still remains, even though it's not easy to cause the issue. Use `MRB_GC_FIXED_ARENA` to avoid the issue for workaround. After this patch, `obj.to_enum` raises `ArgumentError` if the object does not respond to the enumerating method. This is incompatible to CRuby but I think this behavior is better and CRuby should be updated to behave like this. --- mrbgems/mruby-enum-lazy/mrblib/lazy.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mrbgems/mruby-enum-lazy') diff --git a/mrbgems/mruby-enum-lazy/mrblib/lazy.rb b/mrbgems/mruby-enum-lazy/mrblib/lazy.rb index 9227abe8a..e4f116a93 100644 --- a/mrbgems/mruby-enum-lazy/mrblib/lazy.rb +++ b/mrbgems/mruby-enum-lazy/mrblib/lazy.rb @@ -44,7 +44,7 @@ class Enumerator def to_enum(meth=:each, *args, &block) unless self.respond_to?(meth) - raise NoMethodError, "undefined method #{meth}" + raise ArgumentError, "undefined method #{meth}" end lz = Lazy.new(self, &block) lz.obj = self -- cgit v1.2.3