-
-
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
Inconsistent error types for literal powers #24699
Comments
If you want Note that there are lots of non-number types in which you want Note also that if your type defines |
Why must there be The point is that there was no reason to define (The point about inconsistent error types for Base types still stands.) |
Sure, you can overload |
Would you really loose the functionality is you only make the |
(You need to write a If by "Base types" you mean |
Yeah I was referring to types like I don't know if that would be good enough for @thofma who works with Re. |
Only for a few days longer. Once CI is happy enough that we can merge stuff again, #24362 will make it unnecessary and I'll go back through and delete the |
With "Base types" I was mainly thinking of I don't think the error messages are "slightly obscure". In combination with #21014 and missing documentation it is not clear what is going on and why it is failing. Imagine that as a user you just defined Here is another argument against the catchall |
Due to #24240, which for numerical reasons has defined a catchall
Base.literal_pow(::typeof(^), x, ::Type{Val{p}})
for all types, there are now inconsistent error types:This is obviously bad.
The same problem happens if a user defines for his type
T
a functionand is later suprised that
T()^-1
throws aMethodError
, although he defined it for integer exponents. This is further complicated due to #21014, which makes it impossible for a beginner to find out what is actually happening.Defining
inv(::T)
is not an option (it does not make any sense in general). Not every object for which you use^
is a number.What about making the fancy
literal_pow
functions only apply to Base or number types? Together with the catchallthis would solve the problem.
The text was updated successfully, but these errors were encountered: