Skip to content

fix: Only treat frozen Numeric defaults as immutable - #160

Open
jterapin wants to merge 1 commit into
mainfrom
correctness-hygiene
Open

fix: Only treat frozen Numeric defaults as immutable#160
jterapin wants to merge 1 commit into
mainfrom
correctness-hygiene

Conversation

@jterapin

Copy link
Copy Markdown
Contributor

Issue #:

Description of changes:
The _immutable? fast path added in #159 used value.is_a?(Numeric), which matches any Numeric subclass. A mutable custom Numeric subclass used as a default_value was therefore returned by identity and shared across every record in the process, so mutating it on one record leaked into the others.

This guards the numeric branch with frozen?: only genuinely immutable numerics skip the deep copy. Every stdlib numeric is already frozen, so they stay on the fast path and the #159 optimization is preserved; an unfrozen mutable subclass falls back to the existing deep copy.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.


Written with AI assistance and reviewed by jterapin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant