diff --git a/compile.c b/compile.c index cb9d80792a..d4594e84ea 100644 --- a/compile.c +++ b/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); diff --git a/test/ruby/test_iseq.rb b/test/ruby/test_iseq.rb index b4d44e5f28..1a1abc627b 100644 --- a/test/ruby/test_iseq.rb +++ b/test/ruby/test_iseq.rb @@ -433,6 +433,16 @@ class TestISeq < Test::Unit::TestCase assert_iseq_to_binary("@x ||= (1..2)") end + def test_to_binary_pattern_matching + code = "case foo in []; end" + iseq = compile(code) + assert_include(iseq.disasm, "TypeError") + assert_include(iseq.disasm, "NoMatchingPatternError") + EnvUtil.suppress_warning do + assert_iseq_to_binary(code, "[Feature #14912]") + end + end + def test_to_binary_line_info assert_iseq_to_binary("#{<<~"begin;"}\n#{<<~'end;'}", '[Bug #14660]').eval begin;