-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
julep: replace InexactError with something more informative #18521
Comments
This would be great. Could also do something similar for |
That's an interesting idea, and it seems reasonable. I guess the Seems like there's interest. For now I'm going to label this with an "up for grabs" tag, since I have quite a long list of higher priorities. But I may get to it eventually, since I do think it would be an improvement. |
Formatting the string only when printing the error sounds like a good idea, as it allows standardizing it and checking the exception details from code. Ideally, I think we should use distinct exception types for each well-defined error, instead of reusing the same type with variable-length fields. For example, |
A similar approach could be used for |
WIP at #20005, milestone added. |
Trying to convert -1 to a
UInt
justifiably throws an error, but the message isn't very informative:Now that we have good backtraces, it's usually reasonably straightforward to figure out what went wrong, but I don't think anyone would say this is bending over backwards to be friendly to newbies.
Historically, there was a good reason for the use of
InexactError
, which can be seen from the following alternative implementation ofconvert
:This is obviously a much more friendly message. The rub
isappears to be the LLVM:but
Surprisingly this doesn't seem to be as bad as it looks (see below), but at least on older versions of LLVM I suspect this was a performance disaster.
However, now that we have
@noinline
the following alternative implementation is available:for which the LLVM is essentially identical to
convert
:Benchmarking with
indicates that
convert
andiconvert2
have identical performance. (What's quite surprising is that on my machine,iconvert1
performs equally well!)Since there's no performance hit, and since the error message is so much more informative, I recommend we ditch
InexactError
entirely. Or better would probably be to still keep the type (so it can be checked with@test_throws
) but give it a string field that explains the problem.The text was updated successfully, but these errors were encountered: