Skip to content

Commit

Permalink
Merge pull request #54 from timholy/pull-request/b6fdfaf6
Browse files Browse the repository at this point in the history
Fix ambiguity error in ^ on recent 0.6
  • Loading branch information
ajkeller34 authored Feb 18, 2017
2 parents 96bad5d + b6fdfaf commit c0e2438
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Unitful.jl
Original file line number Diff line number Diff line change
Expand Up @@ -506,11 +506,13 @@ end

# Both methods needed for ambiguity resolution
^{T}(x::Dimension{T}, y::Integer) = Dimension{T}(power(x)*y)
^{T,y}(x::Dimension{T}, ::Type{Val{y}}) = Dimension{T}(power(x)*y)
^{T}(x::Dimension{T}, y) = Dimension{T}(power(x)*y)

# A word of caution:
# Exponentiation is not type-stable for `Dimensions` objects.
^{T}(x::Dimensions{T}, y::Integer) = *(Dimensions{map(a->a^y, T)}())
^{T,y}(x::Dimensions{T}, ::Type{Val{y}}) = *(Dimensions{map(a->a^y, T)}())
^{T}(x::Dimensions{T}, y) = *(Dimensions{map(a->a^y, T)}())

@inline dimension{U,D}(u::Unit{U,D}) = D()^u.power
Expand Down Expand Up @@ -1011,12 +1013,14 @@ end

# Both methods needed for ambiguity resolution
^{U,D}(x::Unit{U,D}, y::Integer) = Unit{U,D}(tens(x), power(x)*y)
^{U,D,y}(x::Unit{U,D}, ::Type{Val{y}}) = Unit{U,D}(tens(x), power(x)*y)
^{U,D}(x::Unit{U,D}, y) = Unit{U,D}(tens(x), power(x)*y)

# A word of caution:
# Exponentiation is not type-stable for `Units` objects.
# Dimensions get reconstructed anyway so we pass () for the D type parameter...
^{U,D}(x::Units{U,D}, y::Integer) = *(Units{map(a->a^y, U), ()}())
^{U,D,y}(x::Units{U,D}, ::Type{Val{y}}) = *(Units{map(a->a^y, U), ()}())
^{U,D}(x::Units{U,D}, y) = *(Units{map(a->a^y, U), ()}())

# All of these are needed for ambiguity resolution
Expand Down

0 comments on commit c0e2438

Please sign in to comment.