Skip to content

Commit 3f0a2d9

Browse files
committed
[GR-20446] Make complex and rational frozen when initializing.
PullRequest: truffleruby/1243
2 parents 19b9682 + 72b492c commit 3f0a2d9

File tree

4 files changed

+3
-2
lines changed

4 files changed

+3
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Bug fixes:
5959
* Fixed `String#{upcase!,downcase!,swapcase!}(:ascii)` for non-ASCII-compatible encodings like UTF-16.
6060
* Fixed `String#capitalize!` for strings that weren't full ASCII.
6161
* Fixed enumeration issue in `ENV.{select, filter}`.
62+
* Fixed `Complex` and `Rational` should be frozen after initializing.
6263

6364
Compatibility:
6465

spec/tags/core/kernel/freeze_tags.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/main/ruby/truffleruby/core/complex.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ def Complex.check_real?(obj)
110110
def initialize(a, b = 0)
111111
@real = a
112112
@imag = b
113+
freeze
113114
end
114115

115116
def -@

src/main/ruby/truffleruby/core/rational.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ def self.reduce(num, den)
386386
def initialize(num, den)
387387
@numerator = num
388388
@denominator = den
389+
freeze
389390
end
390391
private :initialize
391392

0 commit comments

Comments
 (0)