-
-
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
@which
and @code_warntype
don't show ^Val{p}
lowering
#21014
Comments
Duplicate (mostly) of #20620. Maybe we can leave this open as a reminder in case literal power and dot operator end up being treated separately. |
Ah, I see, thanks. So is the workaround to use julia> eval(:(@which $(expand(:(m^2)))))
literal_pow(^, m::MyType, ::Type{Val{p}}) where p in Main at REPL[3]:1
julia> eval(:(@code_warntype $(expand(:(m^2)))))
Variables:
#self#::Base.#literal_pow
^::Base.#^
m::MyType
#unused#::Any
Body:
begin
return (Base.add_int)((Core.getfield)(m::MyType, :x)::Int64, $(Expr(:static_parameter, 1)))::Int64
end::Int64 |
Yes, or the alternative but equivalent syntax julia> @eval @which $(expand(:(1^2)))
literal_pow(::Base.#^, x::Union{Complex{#s37} where #s37<:Union{Float32, Float64, Int16, Int32, Int64, Int8, UInt16, UInt32, UInt64, UInt8}, Float32, Float64, Int16, Int32, Int64, Int8, Rational{#s23} where #s23<:Union{Float32, Float64, Int16, Int32, Int64, Int8, UInt16, UInt32, UInt64, UInt8}, UInt16, UInt32, UInt64, UInt8}, ::Type{Val{2}}) in Base at intfuncs.jl:218 |
Would be nice if this is fixed in 0.7. The new literal power stuff breaks existing code and it is quite difficuelt to find out how to fix it. Overload literal_pow? |
Do you have an example of code that is broken by this? |
For my type, in
But for literals it gives me:
I cannot define This is very intransparent for custom types. |
That would be #24240 then, I suppose that |
You don't need to define (If it's crucial that you throw a DomainError, you could define an |
See #24699 |
…w` case. (#53713) The macros `@which`, `@edit`, `@functionloc`, `@less` from `InteractiveUtils`, if applied to the case of literal powers, like `a^12` or `2^-1` used to direct the user to function `^`, while the compiler generates code for `Base.literal_pow`. Now the user is shown the code the compiler generates. Fixes #53691 Fixes #43337 Fixes #21014 Co-authored-by: Matt Bauman <mbauman@juliahub.com>
Cross-posting from discourse: https://discourse.julialang.org/t/incorrect-results-from-which-and-code-warntype-for-literal-powers/2630
I'm trying to use the new literal exponent behavior introduced in #20530 and #20889. I think I'm correctly overloading
literal_pow
, but various macros like@which
,@code_warntype
and others all seem to be showing me the wrong behavior.That's all good so far. But none of the introspection macros seem to work for
m^2
:are the special lowering rules not being applied inside these macros?
The text was updated successfully, but these errors were encountered: