mirror of
https://github.com/ruby/ruby.git
synced 2025-09-18 10:03:59 +02:00
Iseq#to_binary: Add support for NoMatchingPatternError and TypeError
Binary dumping the iseq for `case foo in []; end` used to crash as there was no handling for these exception classes. Pattern matching generates these classes as operands to `putobject`. [Bug #16088] Closes: https://github.com/ruby/ruby/pull/2325
This commit is contained in:
parent
830fd04181
commit
050b932152
2 changed files with 22 additions and 0 deletions
12
compile.c
12
compile.c
|
@ -9853,6 +9853,8 @@ enum ibf_object_class_index {
|
|||
IBF_OBJECT_CLASS_OBJECT,
|
||||
IBF_OBJECT_CLASS_ARRAY,
|
||||
IBF_OBJECT_CLASS_STANDARD_ERROR,
|
||||
IBF_OBJECT_CLASS_NO_MATCHING_PATTERN_ERROR,
|
||||
IBF_OBJECT_CLASS_TYPE_ERROR,
|
||||
};
|
||||
|
||||
struct ibf_object_string {
|
||||
|
@ -9947,6 +9949,12 @@ ibf_dump_object_class(struct ibf_dump *dump, VALUE obj)
|
|||
else if (obj == rb_eStandardError) {
|
||||
cindex = IBF_OBJECT_CLASS_STANDARD_ERROR;
|
||||
}
|
||||
else if (obj == rb_eNoMatchingPatternError) {
|
||||
cindex = IBF_OBJECT_CLASS_NO_MATCHING_PATTERN_ERROR;
|
||||
}
|
||||
else if (obj == rb_eTypeError) {
|
||||
cindex = IBF_OBJECT_CLASS_TYPE_ERROR;
|
||||
}
|
||||
else {
|
||||
rb_obj_info_dump(obj);
|
||||
rb_p(obj);
|
||||
|
@ -9968,6 +9976,10 @@ ibf_load_object_class(const struct ibf_load *load, const struct ibf_object_heade
|
|||
return rb_cArray;
|
||||
case IBF_OBJECT_CLASS_STANDARD_ERROR:
|
||||
return rb_eStandardError;
|
||||
case IBF_OBJECT_CLASS_NO_MATCHING_PATTERN_ERROR:
|
||||
return rb_eNoMatchingPatternError;
|
||||
case IBF_OBJECT_CLASS_TYPE_ERROR:
|
||||
return rb_eTypeError;
|
||||
}
|
||||
|
||||
rb_raise(rb_eArgError, "ibf_load_object_class: unknown class (%d)", (int)cindex);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue