Skip to content

Conversation

@blegat
Copy link
Contributor

@blegat blegat commented Apr 21, 2021

On Julia v1.5.3:

julia> a = big(1 // 1)
1//1

julia> a / zero(a)
1//0

On Julia v1.6.0

julia> a = big(1 // 1)
1//1

julia> a / zero(a)
ERROR: MethodError: no method matching //(::BigFloat, ::BigInt)
Closest candidates are:
  //(::Integer, ::Integer) at rational.jl:61
  //(::Rational, ::Integer) at rational.jl:63
  //(::Complex, ::Real) at rational.jl:77
simonbyrne   ...
Stacktrace:
 [1] //(x::Rational{BigInt}, y::Rational{BigInt})
   @ Base.GMP.MPQ ./gmp.jl:934
 [2] /(x::Rational{BigInt}, y::Rational{BigInt})
   @ Base ./rational.jl:321
 [3] top-level scope
   @ REPL[2]:1

It seems the line was not covered by tests so the PR both fixes the error and adds some tests.

Note that the behavior is still different from Julia v1.5.3 but there is no error and it seems to be the behavior intended by @simonbyrne in #38520

@sostock sostock added backport 1.6 Change should be backported to release-1.6 bugfix This change fixes an existing bug labels Apr 21, 2021
@sostock
Copy link
Contributor

sostock commented Apr 21, 2021

The test failures are due to the type-instability (before this PR, the BigFloat-branch of the method always errored, so it didn’t affect the return type).

Co-authored-by: Sebastian Stock <[email protected]>
blegat and others added 2 commits April 21, 2021 15:58
Co-authored-by: Sebastian Stock <[email protected]>
Co-authored-by: Sebastian Stock <[email protected]>
Copy link
Member

@simonbyrne simonbyrne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks!

@simonbyrne simonbyrne merged commit 2307f80 into JuliaLang:master Apr 21, 2021
KristofferC pushed a commit that referenced this pull request May 4, 2021
* Fix rational division by zero
* Replace `BigFloat` by `BigInt`

Co-authored-by: Sebastian Stock <[email protected]>
(cherry picked from commit 2307f80)
@KristofferC KristofferC mentioned this pull request May 4, 2021
45 tasks
ElOceanografo pushed a commit to ElOceanografo/julia that referenced this pull request May 4, 2021
* Fix rational division by zero
* Replace `BigFloat` by `BigInt`

Co-authored-by: Sebastian Stock <[email protected]>
antoine-levitt pushed a commit to antoine-levitt/julia that referenced this pull request May 9, 2021
* Fix rational division by zero
* Replace `BigFloat` by `BigInt`

Co-authored-by: Sebastian Stock <[email protected]>
johanmon pushed a commit to johanmon/julia that referenced this pull request Jul 5, 2021
* Fix rational division by zero
* Replace `BigFloat` by `BigInt`

Co-authored-by: Sebastian Stock <[email protected]>
@KristofferC KristofferC removed the backport 1.6 Change should be backported to release-1.6 label Jul 12, 2021
staticfloat pushed a commit that referenced this pull request Dec 23, 2022
* Fix rational division by zero
* Replace `BigFloat` by `BigInt`

Co-authored-by: Sebastian Stock <[email protected]>
(cherry picked from commit 2307f80)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix This change fixes an existing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants