diff options
Diffstat (limited to 'encoding.c')
-rw-r--r-- | encoding.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/encoding.c b/encoding.c index 21614245ae..bb6f5b269e 100644 --- a/encoding.c +++ b/encoding.c @@ -880,13 +880,15 @@ enc_compatible_p(VALUE klass, VALUE str1, VALUE str2) { rb_encoding *enc; - if (BUILTIN_TYPE(str1) != T_STRING && BUILTIN_TYPE(str1) != T_REGEXP) { - rb_raise(rb_eTypeError, "wrong argument type %s (expected String or Regexp)", - rb_obj_classname(str1)); + if (SPECIAL_CONST_P(str1) || + BUILTIN_TYPE(str1) != T_STRING && BUILTIN_TYPE(str1) != T_REGEXP) { + rb_raise(rb_eTypeError, "wrong argument type %s (expected String or Regexp)", + rb_obj_classname(str1)); } - if (BUILTIN_TYPE(str2) != T_STRING && BUILTIN_TYPE(str2) != T_REGEXP) { - rb_raise(rb_eTypeError, "wrong argument type %s (expected String or Regexp)", - rb_obj_classname(str2)); + if (SPECIAL_CONST_P(str2) || + BUILTIN_TYPE(str2) != T_STRING && BUILTIN_TYPE(str2) != T_REGEXP) { + rb_raise(rb_eTypeError, "wrong argument type %s (expected String or Regexp)", + rb_obj_classname(str2)); } if (!enc_capable(str1)) return Qnil; if (!enc_capable(str2)) return Qnil; |