Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make String#dup spec-compliant #2100

Merged
merged 7 commits into from
Jun 15, 2024
Merged

Make String#dup spec-compliant #2100

merged 7 commits into from
Jun 15, 2024

Conversation

seven1m
Copy link
Member

@seven1m seven1m commented Jun 15, 2024

#217

I had to go down a rabbit trail on this one to figure out how Kernel#dup works along with initialize_dup and initialize_copy. This blog post was helpful: https://jonleighton.name/2011/initialize_clone-initialize_dup-and-initialize_copy-in-ruby/

seven1m added 7 commits June 15, 2024 07:11
This is for internal use. I'll work on making Kernel#dup more correct
next.
I just noticed this when thinking through Ruby's initialize_copy
semantics. This was no doubt a memory leak.
This was returning false if the integer or double had been turned into a
"real" object.
This blog post helped me better understand how dup, initialize_dup,
initialize_clone, and initialize_copy behave:
https://jonleighton.name/2011/initialize_clone-initialize_dup-and-initialize_copy-in-ruby/

This only fixes Kernel#dup for String, for now, but sets us up to get
all the classes dup'ing properly in the future.
I use it like this:

    GLOB='spec/**/dup_spec.rb' DEBUG=true \
    ruby test/ruby/ruby_specs_test.rb

...so I can see debugging output when the specs are passing.
@seven1m seven1m merged commit 2543562 into master Jun 15, 2024
15 checks passed
@seven1m seven1m deleted the string-dup branch June 15, 2024 15:08
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