Open nsajko opened 1 month ago
The bigger issue is that this should probably just work.
Made a separate issue about that: #55961
Here's a standalone example for this issue, independent of Irrational
:
julia> struct S <: Real end
julia> Base.:(*)(::S, ::S) = S()
julia> Base.isone(::S) = false
julia> Base.:(-)(::S) = S()
julia> e = -1; S() ^ e
ERROR: DomainError with -1:
Cannot raise an integer x to a negative power -1.
Convert input to float.
Stacktrace:
[1] throw_domerr_powbysq(::S, p::Int64)
@ Base ./intfuncs.jl:302
[2] power_by_squaring(x_::S, p::Int64; mul::typeof(*))
@ Base ./intfuncs.jl:327
[3] power_by_squaring
@ ./intfuncs.jl:316 [inlined]
[4] ^(x::S, p::Int64)
@ Base ./intfuncs.jl:352
[5] top-level scope
@ REPL[5]:1
julia> versioninfo()
Julia Version 1.12.0-DEV.1282
Commit dd310849adb (2024-10-01 18:56 UTC)
Build Info:
Official https://julialang.org release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 8 × AMD Ryzen 3 5300U with Radeon Graphics
WORD_SIZE: 64
LLVM: libLLVM-18.1.7 (ORCJIT, znver2)
NB: there's nothing special about
π
here, all unknown (not-floating-point?) types seem to be regarded as integer by the error message.