Actions
Feature #13983
closedRational and Complex should be frozen
Description
Since they basically are value types.
They also do not support #dup currently:
> 1r.dup
TypeError: can't copy Rational
from `initialize_copy'
> 1i.dup
TypeError: can't copy Complex
from `initialize_copy'
Changing their value can only be considered a semantic bug.
So, let's follow true/false/nil/Integer/Float and friends?
Not sure what #6538 was about but I think Marshal can just freeze after setting the values.
It's slightly incompatible if people do rational.instance_variable_set(:@foo, 1) or so,
but no more than on other now-frozen Numeric types and this kind of code seems highly undesirable.
Updated by Eregon (Benoit Daloze) about 7 years ago
- Related to Feature #13985: Avoid exception for #dup/#clone on Rational and Complex added
Updated by matz (Yukihiro Matsumoto) about 7 years ago
Agreed.
Matz.
Updated by nobu (Nobuyoshi Nakada) about 7 years ago
- Status changed from Open to Closed
Updated by Eregon (Benoit Daloze) about 7 years ago
- Target version set to 2.5
nobu (Nobuyoshi Nakada) wrote:
Applied in changeset trunk|r60214.
Thank you nobu for the patch!
I'll write some specs for it :)
Updated by Eregon (Benoit Daloze) about 7 years ago
Specs added in r60505
Actions
Like0
Like0Like0Like0Like0Like0Like0