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

UInt(-1) yields an obscure error message #30247

Closed
staticfloat opened this issue Dec 3, 2018 · 2 comments · Fixed by #53166
Closed

UInt(-1) yields an obscure error message #30247

staticfloat opened this issue Dec 3, 2018 · 2 comments · Fixed by #53166
Labels
display and printing Aesthetics and correctness of printed representations of objects. error handling Handling of exceptions by Julia or the user

Comments

@staticfloat
Copy link
Member

It would be nice if this error was a little less opaque; even something like DomainError would be easier to understand than InexactError: check_top_bit(Int64, -1).

julia> UInt(-1)
ERROR: InexactError: check_top_bit(Int64, -1)
Stacktrace:
 [1] throw_inexacterror(::Symbol, ::Any, ::Int64) at ./boot.jl:567
 [2] check_top_bit at ./boot.jl:581 [inlined]
 [3] toUInt64 at ./boot.jl:692 [inlined]
 [4] UInt64(::Int64) at ./boot.jl:722
 [5] top-level scope at none:0
@staticfloat staticfloat added error handling Handling of exceptions by Julia or the user display and printing Aesthetics and correctness of printed representations of objects. labels Dec 3, 2018
@JeffBezanson
Copy link
Member

See also #29766

@kim366
Copy link
Contributor

kim366 commented Dec 4, 2018

We could catch in the UInt constructor and rethrow; I don't know the performance implications of this, though.

The related code snippets are

function check_top_bit(x)

and
UInt64(x::BuiltinInts) = toUInt64(x)::UInt64

vtjnash added a commit that referenced this issue Feb 3, 2024
staticfloat pushed a commit that referenced this issue Feb 5, 2024
Fixes #30247

@staticfloat this was your issue, so what do you think of this? I think
the main problem was already solved (showing the wrong type), but I am
wondering if this wording is still clearer, since it tries to align it
with functions users might actually have encountered (trunc, convert,
signbit)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
display and printing Aesthetics and correctness of printed representations of objects. error handling Handling of exceptions by Julia or the user
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants