Skip to content

Fix sprinf with explicit zero precision and zero value#8769

Merged
enebo merged 1 commit intojruby:masterfrom
Earlopain:d-format-precision-zero
Apr 16, 2025
Merged

Fix sprinf with explicit zero precision and zero value#8769
enebo merged 1 commit intojruby:masterfrom
Earlopain:d-format-precision-zero

Conversation

@Earlopain
Copy link
Contributor

In that case, nothing is written. It's documented: https://docs.ruby-lang.org/en/3.4/format_specifications_rdoc.html#:~:text=if%20the%20precision%20is%200%20and%20the%20value%20is%200%2C%20nothing%20is%20written

NOTE: I found this code quite hard to follow and there was at least one other place I contemplated implementing a fix. Not sure if what I chose is in fact the best place for a fix.

@enebo enebo added this to the JRuby 10.0.1.0 milestone Apr 15, 2025
@enebo
Copy link
Member

enebo commented Apr 16, 2025

I have an ancient branch (#6913) which rewrites much of this but I got stuck on dtoa impl. We know this is horrifically messy and your fix looks fine even if it "maybe" could be somewhere else. As it stands this fixes the issue with new specs. LGTM. Also you may be passing some more tests in test/mri/ruby/test_sprintf_comb.rb (another fun piece of code).

@enebo enebo merged commit c3923e8 into jruby:master Apr 16, 2025
71 of 72 checks passed
Earlopain added a commit to Earlopain/rubocop that referenced this pull request Aug 12, 2025
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.

2 participants