Issue #1852 has been updated by Marc-Andre Lafortune.

File hash_additional.diff added
File hash_merged.diff added
Assigned to set to Marc-Andre Lafortune
Target version set to 1.9.2

I wanted to use rb_catch_obj at first but I saw the following issues:

1) rb_catch_obj sends :catch to nil. If for some strange evil purpose catch was redefined by the user (in Kernel, Object or as a singleton method of nil), then [].hash would call that code, which seems like a bad idea. I believe that #hash's use of throw & catch should be invisible to the user.

2) rb_catch_obj creates an instruction sequence. As such, it will show if "caller" is called within #hash, or in the backtrace of exceptions raised within #hash. Again I feel it should be invisible.

3) rb_catch_obj creates a temporary object to hold the instruction sequence (NEW_IFUNC). I lack the experience to be certain on how big of a performance penalty if would be, but I didn't like the idea of creating an object for every #hash call and leaving it for the GC to handle later.

I agree that it would be best to factorize the TAG_THROW handling. I extracted it from rb_f_catch and created a new function "rb_catch_func" that does the low-level catching. Using this new function for #hash should have negligible performance impacts compared to my previous version. I've attached the resulting patch in two formats. Is this ok?
----------------------------------------
http://redmine.ruby-lang.org/issues/show/1852

----------------------------------------
http://redmine.ruby-lang.org