Skip to content

improve type stability? #109

@stevengj

Description

@stevengj

Currently, it seems like most of the operations are type-unstable:

julia> using SIUnits, SIUnits.ShortUnits, Base.Test

julia> @inferred 1m
ERROR: return type SIUnits.SIQuantity{Int64,1,0,0,0,0,0,0,0,0} does not match inferred return type Union{Int64,SIUnits.SIQuantity{T<:Number,m,kg,s,A,K,mol,cd,rad,sr}}
 in error(::String) at ./error.jl:21
 in error(::String) at /Applications/Julia-0.5.app/Contents/Resources/julia/lib/julia/sys.dylib:?

julia> x = 1m
1 m

julia> @inferred x*x
ERROR: return type SIUnits.SIQuantity{Int64,2,0,0,0,0,0,0,0,0} does not match inferred return type Union{Int64,SIUnits.SIQuantity{T<:Number,m,kg,s,A,K,mol,cd,rad,sr}}
 in error(::String) at ./error.jl:21
 in error(::String) at /Applications/Julia-0.5.app/Contents/Resources/julia/lib/julia/sys.dylib:?

It seems like there is enough information available to determine these exponents at compile time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions