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

Changed check_top_bit InexactError #33202

Merged
merged 1 commit into from
Sep 11, 2019

Conversation

jakobnissen
Copy link
Contributor

Currently, converting type of a too large or small integer yields this error message:

julia> UInt(-1)
ERROR: InexactError: check_top_bit(Int64, -1)

However, the documentation of InexactError states:

  InexactError(name::Symbol, T, val)

  Cannot exactly convert val to type T in a method of function name.

This implies that the above error message means that -1 cannot be represented as an Int64. However, that's wrong - it cannot be represented as a UInt64. Furthermore, check_top_bit(Int64, -1) is not a valid function call.

With this change, the error message is:

julia> UInt(-1)
ERROR: InexactError: check_top_bit(UInt64, -1)

Which is correct. Also, check_top_bit now takes a type and a value, so check_top_bit(UInt64, -1) is a valid function call (and is also indeed the call that triggered the error).

There's probably a larger discussion to be had whether it should really be a DomainError instead, but changing the error type is a breaking change.
Also see issue #30247 and issue #29766 .

@JeffBezanson JeffBezanson added the error handling Handling of exceptions by Julia or the user label Sep 10, 2019
@JeffBezanson
Copy link
Member

Thank you, and welcome! Very good first PR. This looks like quite an oversight. Since this is pretty low-level I'll run benchmarks just in case

@nanosoldier runbenchmarks(ALL, vs = ":master")

@JeffBezanson JeffBezanson added the bugfix This change fixes an existing bug label Sep 10, 2019
@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

@JeffBezanson JeffBezanson merged commit c48126f into JuliaLang:master Sep 11, 2019
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 error handling Handling of exceptions by Julia or the user
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants