Skip to content

Instantly share code, notes, and snippets.

@ivirshup
Created May 2, 2016 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivirshup/60157f58650915bf95fb4c0de5e95128 to your computer and use it in GitHub Desktop.
Save ivirshup/60157f58650915bf95fb4c0de5e95128 to your computer and use it in GitHub Desktop.
auto_unbox error weirdness
julia> using Combinatorics
julia> function foo()
ts = filter(x->isa(x, DataType), map(eval, names(Base)))
for x in ts
end
permutations(ts, 2)
end
foo (generic function with 1 method)
julia> foo()
Combinatorics.Permutations{Array{Any,1}}(Any[Pair{A,B},AbstractChannel,AbstractRNG,AbstractSparseArray{Tv,Ti,N},ArgumentError,Array{T,N},AssertionError,Associative{K,V},Base64DecodePipe,Base64EncodePipe … Union,UnitRange{T<:Real},UpperTriangular{T,S<:AbstractArray{T,2}},Val{T},VersionNumber,UTF32String,WeakKeyDict{K,V},WorkerConfig,WorkerPool,Zip{I,Z<:Base.AbstractZipIterator}],2)
julia> @code_lowered foo()
1-element Array{Any,1}:
LambdaInfo for foo
:(begin # REPL[2], line 2:
#1 = $(Expr(:new, :(Main.##1#2)))
GenSym(0) = #1
GenSym(1) = (Main.map)(Main.eval,(Main.names)(Main.Base))
ts = (Main.filter)(GenSym(0),GenSym(1)) # REPL[2], line 3:
GenSym(2) = ts
#temp# = (top(start))(GenSym(2))
9:
unless (top(!))((top(done))(GenSym(2),#temp#)) goto 16
GenSym(3) = (top(next))(GenSym(2),#temp#)
x = (top(getfield))(GenSym(3),1)
#temp# = (top(getfield))(GenSym(3),2)
14:
goto 9
16:
17: # REPL[2], line 5:
return (Main.permutations)(ts,2)
end)
julia> @code_typed foo()
1-element Array{Any,1}:
LambdaInfo for foo
:(begin # REPL[2], line 2:
#1 = $(Expr(:new, :(Main.##1#2)))
GenSym(0) = #1 # reflection.jl, line 32: # reflection.jl, line 30:
GenSym(4) = (Base.box)(Int32,(Base.zext_int)(Int32,false))
GenSym(5) = (Base.box)(Int32,(Base.zext_int)(Int32,false))
GenSym(1) = (Main.map)(Main.eval,(Base.sort!)((top(ccall))(:jl_module_names,(top(apply_type))(Base.Array,Base.Symbol,1)::Type{Array{Symbol,1}},(top(svec))(Base.Any,Base.Int32,Base.Int32)::SimpleVector,Main.Base,0,GenSym(4),0,GenSym(5),0)::Array{Symbol,1})::Array{Symbol,1})::AbstractArray{T,N}
ts = (Main.filter)(GenSym(0),GenSym(1)) # REPL[2], line 3:
GenSym(2) = ts
#temp# = (top(start))(GenSym(2))
13:
unless (top(!))((top(done))(GenSym(2),#temp#)) goto 20
GenSym(3) = (top(next))(GenSym(2),#temp#)
x = (top(getfield))(GenSym(3),1)
#temp# = (top(getfield))(GenSym(3),2)
18:
goto 13
20:
21: # REPL[2], line 5:
return (Main.permutations)(ts,2)::Combinatorics.Permutations{T}
end::Combinatorics.Permutations{T})
julia> function foo()
ts = filter(x->isa(x, DataType), map(eval, names(Base)))
for x in ts
end
permutations(ts, 2)
end
WARNING: Method definition foo() in module Main at REPL[2]:2 overwritten at REPL[6]:2.
foo (generic function with 1 method)
julia> foo()
ERROR: auto_unbox: unable to determine argument type
[inlined code] from /Users/isaac/.julia/v0.5/Combinatorics/src/permutations.jl:30
in foo() at ./REPL[6]:5
in eval(::Module, ::Any) at ./boot.jl:236
julia> @code_lowered foo()
1-element Array{Any,1}:
LambdaInfo for foo
:(begin # REPL[6], line 2:
#3 = $(Expr(:new, :(Main.##3#4)))
GenSym(0) = #3
GenSym(1) = (Main.map)(Main.eval,(Main.names)(Main.Base))
ts = (Main.filter)(GenSym(0),GenSym(1)) # REPL[6], line 3:
GenSym(2) = ts
#temp# = (top(start))(GenSym(2))
9:
unless (top(!))((top(done))(GenSym(2),#temp#)) goto 16
GenSym(3) = (top(next))(GenSym(2),#temp#)
x = (top(getfield))(GenSym(3),1)
#temp# = (top(getfield))(GenSym(3),2)
14:
goto 9
16:
17: # REPL[6], line 5:
return (Main.permutations)(ts,2)
end)
julia> @code_typed foo()
1-element Array{Any,1}:
LambdaInfo for foo
:(begin # REPL[6], line 2:
#3 = $(Expr(:new, :(Main.##3#4)))
GenSym(0) = #3 # reflection.jl, line 32: # reflection.jl, line 30:
GenSym(4) = (Base.box)(Int32,(Base.zext_int)(Int32,false))
GenSym(5) = (Base.box)(Int32,(Base.zext_int)(Int32,false))
GenSym(6) = (Base.sort!)((top(ccall))(:jl_module_names,(top(apply_type))(Base.Array,Base.Symbol,1)::Type{Array{Symbol,1}},(top(svec))(Base.Any,Base.Int32,Base.Int32)::SimpleVector,Main.Base,0,GenSym(4),0,GenSym(5),0)::Array{Symbol,1})::Array{Symbol,1} # abstractarray.jl, line 1119: # generator.jl, line 10: # generator.jl, line 10:
(top(getfield))(Base,:Generator)::Type{Base.Generator{I,F}}
GenSym(1) = (Base.collect_similar)(GenSym(6),$(Expr(:new, Base.Generator{Array{Symbol,1},Core.#eval}, :(Main.eval), GenSym(6))))::AbstractArray{T,N}
ts = (Main.filter)(GenSym(0),GenSym(1)) # REPL[6], line 3:
GenSym(2) = ts
#temp#@_4 = (top(start))(GenSym(2))
18:
unless (top(!))((top(done))(GenSym(2),#temp#@_4)) goto 25
GenSym(3) = (top(next))(GenSym(2),#temp#@_4)
x = (top(getfield))(GenSym(3),1)
#temp#@_4 = (top(getfield))(GenSym(3),2)
23:
goto 18
25:
26: # REPL[6], line 5:
#temp#@_6 = 2 # /Users/isaac/.julia/v0.5/Combinatorics/src/permutations.jl, line 30:
unless (Base.slt_int)(#temp#@_6,0)::Bool goto 33 # /Users/isaac/.julia/v0.5/Combinatorics/src/permutations.jl, line 31:
#temp#@_6 = (Combinatorics.length)(ts) + 1
33: # /Users/isaac/.julia/v0.5/Combinatorics/src/permutations.jl, line 33:
return (Combinatorics.Permutations)(ts,#temp#@_6)::Combinatorics.Permutations{T}
end::Combinatorics.Permutations{T})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment