JuliaPhysics / JuliaPhysics/Unitful.jl

insufficient constant propagation for unit exponentiation with floating-point exponent

Open
#787 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
675
Forks
124
Avg merge
3h 38m
Merged PRs (30d)
1

Description

Hello, I found a use case where `uconvertrp` becomes type instable:
```julia
using Unitful, Unitful.DefaultSymbols
function tmp(a, b)
uconvertp(NoUnits, a * (b ^ (3/2)))
end

julia> @code_warntype tmp(10u"dB/cm^(3/2)", 10cm)
MethodInstance for tmp(::Quantity{Gain{Unitful.LogInfo{:Decibel, 10, 10}, :?, Int64}, 𝐋^-3/2, Unitful.FreeUnits{(cm^-3/2,), 𝐋^-3/2, nothing}}, ::Quantity{Int64, 𝐋, Un
itful.FreeUnits{(cm,), 𝐋, nothing}})
from tmp(a, b) @ Main REPL[61]:1
Arguments
#self#::Core.Const(Main.tmp)
a::Quantity{Gain{Unitful.LogInfo{:Decibel, 10, 10}, :?, Int64}, 𝐋^-3/2, Unitful.FreeUnits{(cm^-3/2,), 𝐋^-3/2, nothing}}
b::Quantity{Int64, 𝐋, Unitful.FreeUnits{(cm,), 𝐋, nothing}}
Body::Any
1 ─ %1 = Main.uconvertp::Core.Const(Unitful.uconvertp)
│ %2 = Main.NoUnits::Core.Const()
│ %3 = Main.:*::Core.Const(*)
│ %4 = Main.:^::Core.Const(^)
│ %5 = (3 / 2)::Core.Const(1.5)
│ %6 = (%4)(b, %5)::Any
│ %7 = (%3)(a, %6)::Any
│ %8 = (%1)(%2, %7)::Any
└── return %8
```
Thanks

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.