diff options
author | Nobuyoshi Nakada <[email protected]> | 2021-06-03 13:26:11 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2021-06-03 15:11:18 +0900 |
commit | 9f3888d6a3387773c8707b7971ce64c60df33d36 (patch) | |
tree | fae4b74a9d319ec899399d84cb9d6bd43c27a480 /compile.c | |
parent | 37eb5e74395f148782f7d67b5218fb2e66b113d7 (diff) |
Warn more duplicate literal hash keys
Following non-special_const literals:
* T_REGEXP
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4548
Diffstat (limited to 'compile.c')
-rw-r--r-- | compile.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -2011,6 +2011,9 @@ rb_iseq_cdhash_cmp(VALUE val, VALUE lit) const struct RComplex *comp2 = RCOMPLEX(lit); return rb_iseq_cdhash_cmp(comp1->real, comp2->real) || rb_iseq_cdhash_cmp(comp1->imag, comp2->imag); } + else if (tlit == T_REGEXP) { + return rb_reg_equal(val, lit) ? 0 : -1; + } else { UNREACHABLE_RETURN(-1); } @@ -2033,6 +2036,8 @@ rb_iseq_cdhash_hash(VALUE a) return rb_rational_hash(a); case T_COMPLEX: return rb_complex_hash(a); + case T_REGEXP: + return NUM2LONG(rb_reg_hash(a)); default: UNREACHABLE_RETURN(0); } |