summaryrefslogtreecommitdiff
path: root/range.c
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2020-09-25 18:05:55 +0900
committerKoichi Sasada <ko1@atdot.net>2020-09-25 22:16:55 +0900
commit0096d2b895395df5ab8696d3b6d444dc1b7730b6 (patch)
tree21aa9c7e0eab7304433d05b6bce6f5b26f5e1d95 /range.c
parentf4328d7f5d035b5a292d00ad21e79818b9220d8b (diff)
freeze all Range objects.v3_0_0_preview1
Matz want to try to freeze all Range objects. [Feature #15504]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3583
Diffstat (limited to 'range.c')
-rw-r--r--range.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/range.c b/range.c
index 224e5d3336e..17d29925f1d 100644
--- a/range.c
+++ b/range.c
@@ -58,6 +58,10 @@ range_init(VALUE range, VALUE beg, VALUE end, VALUE exclude_end)
RANGE_SET_EXCL(range, exclude_end);
RANGE_SET_BEG(range, beg);
RANGE_SET_END(range, end);
+
+ if (CLASS_OF(range) == rb_cRange) {
+ rb_obj_freeze(range);
+ }
}
VALUE