-
-
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
splatting is type-unstable with parametric type argument #22327
Comments
my_construct(::Type{Complex}, a) = 1
my_construct(::Type{Array}, a) = 1.0
function foo(x)
args = (Array, x)
my_construct(args...)
end
@code_warntype foo(1) |
|
That would be great! |
aka #10980 ? |
julia> function foo(x)
args = (Array, x)
args[1]
end
foo (generic function with 1 method)
julia> @code_warntype foo(1)
Variables:
#self#::#foo
x::Int64
args::Any
Body:
begin
SSAValue(0) = Main.Array
SSAValue(1) = x::Int64
#= line 3 =#
return SSAValue(0)
end::UnionAll
julia> function foo(x)
args = (Array, 1)
args[1]
end
foo (generic function with 1 method)
julia> @code_warntype foo(1)
Variables:
#self#::#foo
x::Int64
args::Any
Body:
begin
SSAValue(0) = Main.Array
#= line 3 =#
return SSAValue(0)
end::Type{Array} So unless EDIT: julia> typeof((Array,1))
Tuple{UnionAll,Int64} Inferring that as |
This is fixed. |
Perhaps that's not its strictly-intended usage, but I've found it useful to temporarily pepper my code with
@inferred
to catch type-instabilities. Unfortunately, it seems that the output of@inferred
can be type-unstable (0.6, rc2), which is an issue for checking the type-stability of heterogeneous tree traversal algorithms.The text was updated successfully, but these errors were encountered: