Skip to content

Inference failure for typed concatenation #13254

Closed
@GunnarFarneback

Description

@GunnarFarneback

The typed concatenation T[a:b] is deprecated in favor of T[a:b;]. However, the latter fails to infer result type correctly.

   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.4.0-rc2+10 (2015-09-20 15:38 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit d8930a0* (0 days old release-0.4)
|__/                   |  x86_64-linux-gnu

julia> f(n) = Float64[1:n]
f (generic function with 1 method)

julia> g(n) = Float64[1:n;]
g (generic function with 1 method)

julia> f(2)
WARNING: T[a:b] concatenation is deprecated; use T[a:b;] instead
 in depwarn at ./deprecated.jl:73
 in getindex at ./deprecated.jl:662
 in f at ./none:1
while loading no file, in expression starting on line 0
2-element Array{Float64,1}:
 1.0
 2.0

julia> g(2)
2-element Array{Float64,1}:
 1.0
 2.0

julia> Base.return_types(f, (Int,))
1-element Array{Any,1}:
 Array{Float64,1}

julia> Base.return_types(g, (Int,))
1-element Array{Any,1}:
 Array{Float64,N}

Metadata

Metadata

Assignees

No one assigned

    Labels

    potential benchmarkCould make a good benchmark in BaseBenchmarksregressionRegression in behavior compared to a previous version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions