Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix BigDecimal support on Ruby 2.7 #50

Merged
merged 2 commits into from
May 24, 2021

Conversation

diego-silva
Copy link
Contributor

@diego-silva diego-silva commented May 21, 2021

BigDecimal.new was deprecated on Ruby 2.6 and removed on Ruby 2.7. See more here.
The alternative is to use BigDecimal() which is supported on all rubies currently tested on this repo (2.4+).

This PR adds a reproducible test case for this BigDecimal issue, which fails on Ruby 2.7 before the proposed fix.

@codecov
Copy link

codecov bot commented May 21, 2021

Codecov Report

Merging #50 (33013f1) into master (1fb3708) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #50      +/-   ##
==========================================
+ Coverage   99.07%   99.09%   +0.01%     
==========================================
  Files           6        6              
  Lines         325      331       +6     
==========================================
+ Hits          322      328       +6     
  Misses          3        3              
Impacted Files Coverage Δ
lib/sorbet-coerce/converter.rb 97.14% <100.00%> (+0.05%) ⬆️
spec/coerce_spec.rb 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1fb3708...33013f1. Read the comment docs.

@diego-silva diego-silva mentioned this pull request May 21, 2021
@donaldong
Copy link
Contributor

Thanks! @diego-silva

@donaldong donaldong merged commit bd9393c into chanzuckerberg:master May 24, 2021
@diego-silva diego-silva deleted the bigdecimals branch May 24, 2021 20:18
@donaldong donaldong mentioned this pull request May 24, 2021
donaldong added a commit that referenced this pull request May 24, 2021
Bug Fixes
- Fix BigDecimal support on Ruby 2.7 #50
donaldong added a commit that referenced this pull request May 24, 2021
Bug Fixes
- Fix BigDecimal support on Ruby 2.7 #50
@kyku
Copy link

kyku commented Jun 1, 2021

TypeCoerce[BigDecimal].new.from(3.1415)
Traceback (most recent call last):
/home/kyku/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/sorbet-coerce-0.5.0/lib/sorbet-coerce/converter.rb:134:in `BigDecimal': can't omit precision for a Float. (ArgumentError)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants