Skip to content
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

Error when displaying results of methods in REPL #9471

Closed
yuyichao opened this issue Dec 27, 2014 · 14 comments
Closed

Error when displaying results of methods in REPL #9471

yuyichao opened this issue Dec 27, 2014 · 14 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@yuyichao
Copy link
Contributor

There's a weird error when showing the result of methods function in REPL.
E.g.

julia> methods(length, (Any,))
65-element Array{Any,1}:
Error showing value of type Array{Any,1}:
ERROR: type TypeConstructor has no field name
 in show at ./show.jl:83
 in show at ./expr.jl:53
 in show_delim_array at ./show.jl:187
 in show at ./show.jl:85
 in print_to_string at /usr/lib/julia/sys.so
 in argtype_decl at ./methodshow.jl:18
 in arg_decl_parts at ./methodshow.jl:30
 in show at ./methodshow.jl:36
 in showcompact_lim at ./show.jl:93
 in sprint at ./iostream.jl:230
 in alignment at ./show.jl:851
 in alignment at ./show.jl:883
 in print_matrix at ./show.jl:983
 in print_matrix at ./show.jl:950
 in anonymous at ./replutil.jl:21
 in with_output_limit at /usr/lib/julia/sys.so
 in writemime at ./replutil.jl:21
 in display at ./REPL.jl:119
 in display at ./REPL.jl:121
 in display at ./multimedia.jl:149
 in print_response at ./REPL.jl:140
 in print_response at ./REPL.jl:125
 in anonymous at ./REPL.jl:597
 in run_interface at /usr/lib/julia/sys.so
 in run_frontend at /usr/lib/julia/sys.so
 in run_repl at /usr/lib/julia/sys.so
 in _start at /usr/lib/julia/sys.so
julia> methods(length)
#65 methods for generic function "length":                                        
length(mt::MethodTable) at reflection.jl:133                                       
length(t::(Any...,)) at tuple.jl:3                                                 
length{T<:Union(UInt64,Int64)}(r::StepRange{T<:Union(UInt64,Int64),S}) at range.jl:189                                                                                
length{T<:Union(UInt8,UInt16,Int16,UInt32,Int32,Int8)}(r::StepRange{T<:Union(UInt8,UInt16,Int16,UInt32,Int32,Int8),S}) at range.jl:209                                
length{T<:Base.Dates.TimeType}(r::StepRange{T<:Base.Dates.TimeType,S}) at dates/ranges.jl:17                                                                          
length{P<:Base.Dates.Period}(r::StepRange{P<:Base.Dates.Period,S}) at dates/ranges.jl:19                                                                              
length(r::StepRange{T,S}) at range.jl:182                                          
length{T<:Union(UInt64,Int64)}(r::UnitRange{T<:Union(UInt64,Int64)}) at range.jl:199                                                                                  
length{T<:Union(UInt8,UInt16,Int16,UInt32,Int32,Int8)}(r::UnitRange{T<:Union(UInt8,UInt16,Int16,UInt32,Int32,Int8)}) at range.jl:213                                  
length(r::UnitRange{T<:Real}) at range.jl:185                                      
length(r::FloatRange{T<:FloatingPoint}) at range.jl:186                            
length(x::Number) at number.jl:12                                                  
length(V::SubArray{T,N,P<:AbstractArray{T,N},I<:(Union(Range{Int64},Int64,Array{Int64,1},Colon)...,),LD}) at subarray.jl:23                                           
length(a::Array{T,N}) at array.jl:21                                               
length(B::BitArray{N}) at bitarray.jl:42                                           
length(S::SharedArray{T,N}) at sharedarray.jl:118                                  
length(t::AbstractArray{T,N}) at abstractarray.jl:24
length(s::IntSet) at intset.jl:172
length(v::Union(ValueIterator{T<:Associative{K,V}},KeyIterator{T<:Associative{K,V}})) at dict.jl:144
length(d::ObjectIdDict) at dict.jl:310
length(t::Dict{K,V}) at dict.jl:709
length(t::WeakKeyDict{K,V}) at dict.jl:785
length(s::Set{T}) at set.jl:22
length(e::Enumerate{I}) at iterator.jl:10
length(z::Zip{I<:(Any...,)}) at iterator.jl:30
length(z::Zip2{I1,I2}) at iterator.jl:54
length(c::Char) at char.jl:18
length(s::UTF8String) at utf8.jl:40
length(s::UTF32String) at utf32.jl:16
length(s::DirectIndexString) at string.jl:79
length{T<:DirectIndexString}(s::SubString{T<:DirectIndexString}) at string.jl:597
length(s::SubString{UTF8String}) at string.jl:600
length(s::RepString) at string.jl:689
length(s::RevString{T<:AbstractString}) at string.jl:738
length(s::RopeString) at string.jl:802
length(s::AbstractString) at string.jl:81
length(g::Base.UTF8proc.GraphemeIterator{S<:AbstractString}) at utf8proc.jl:189
length(::EnvHash) at env.jl:160
length(pq::Base.Collections.PriorityQueue{K,V,O<:Base.Order.Ordering}) at collections.jl:166
length(c::Combinations{T}) at combinatorics.jl:249
length(c::Permutations{T}) at combinatorics.jl:289
length(p::IntegerPartitions) at combinatorics.jl:322
length(f::FixedPartitions) at combinatorics.jl:388
length(p::SetPartitions{T<:AbstractArray{T,1}}) at combinatorics.jl:450
lengthError showing value of type MethodTable:
ERROR: type TypeConstructor has no field name
 in show at ./show.jl:83
 in show at ./expr.jl:53
 in show_delim_array at ./show.jl:187
 in show at ./show.jl:85
 in print_to_string at /usr/lib/julia/sys.so
 in argtype_decl at ./methodshow.jl:18
 in arg_decl_parts at ./methodshow.jl:30
 in show at ./methodshow.jl:36
 in show_method_table at ./methodshow.jl:62
 in show at ./methodshow.jl:74
 in anonymous at ./show.jl:1180
 in with_output_limit at /usr/lib/julia/sys.so
 in showlimited at ./show.jl:1179
 in writemime at ./replutil.jl:2
 in display at ./REPL.jl:119
 in display at ./REPL.jl:121
 in display at ./multimedia.jl:149
 in print_response at ./REPL.jl:140
 in print_response at ./REPL.jl:125
 in anonymous at ./REPL.jl:597
 in run_interface at /usr/lib/julia/sys.so
 in run_frontend at /usr/lib/julia/sys.so
 in run_repl at /usr/lib/julia/sys.so
 in _start at /usr/lib/julia/sys.so
@nalimilan
Copy link
Member

Thanks for the report. Could you post the output of versioninfo()?

@yuyichao
Copy link
Contributor Author

It's the latest master compiled a few hours ago

julia> versioninfo()
Julia Version 0.4.0-dev+2272
Commit c9c89a4* (2014-12-26 19:30 UTC)
Platform Info:
  System: Linux (x86_64-unknown-linux-gnu)
  CPU: Intel(R) Core(TM) i7-4702HQ CPU @ 2.20GHz
  WORD_SIZE: 64
  BLAS: libblas
  LAPACK: liblapack
  LIBM: libm
  LLVM: libLLVM-3.3

But I also remember seeing this a few days ago as well (with the master at that time).

@yuyichao
Copy link
Contributor Author

I can also reproduce it with d6514f4 but 0.3.3 release (in ArchLinux repo) is fine.

@yuyichao
Copy link
Contributor Author

Sorry, I've just noticed that this is actually related to me defining another method for show in a package that get loaded in my .juliarc for REPL. It doesn't trigger if I use julia -f.

I still think it is a bug though. The simplified code that reproduce this on 0.3.3 or later (don't have a earlier version to test) is

type T
end

function Base.show(io::Base.IO, ::Type{T})
end

println(methods(length))

There isn't any warning/error when defining that method. The error only appears when I try to print the result of methods() (or similar), which looks really weird for me .....

@yuyichao
Copy link
Contributor Author

(Hopefully it isn't very unreasonable to redefine how a custom type (the type itself) should be printed)

@yuyichao
Copy link
Contributor Author

I've tracked down the call chain a little bit more and it looks that it is somehow related to the compiler and I don't think I know enough to track it down further.

So here is what I've observed

  1. The code I post above fails
  2. It fails when trying to print the following method
    julia length(p::SetPartitions{T<:AbstractArray{T,1}}) at combinatorics.jl:450
  3. If show(IOBuffer(), Base.SetPartitions.parameters[1].ub) is called before println(methods(length)) (doesn't matter if it is called before or after the custome method for show is defined), there's no error. If it is called after println(methods(length)), it fails at the same point.
  4. Calling show(STDOUT, Base.SetPartitions.parameters[1].ub) does not help.

@yuyichao
Copy link
Contributor Author

What makes even less sense is that when it throws an error on

show(IOBuffer(), Base.SetPartitions.parameters[1].ub)

The following code does not throw any error.......

meth = @which show(IOBuffer(), Base.SetPartitions.parameters[1].ub)
meth.func(IOBuffer(), Base.SetPartitions.parameters[1].ub)

WTF?... = = ................

@yuyichao
Copy link
Contributor Author

I've also just reproduce it on the (out-of-date) version installed on x.dialup.mit.edu (0.3.1-pre+40, release-0.3/795bc31) so it shouldn't be sth wrong with my build.

P.S. Anyone mind updating that version?....

@Keno Keno added the bug Indicates an unexpected problem or unintended behavior label Dec 28, 2014
@Keno
Copy link
Member

Keno commented Dec 28, 2014

Yes, I agree this looks like bug.

@jakebolewski
Copy link
Member

This seems to be fixed, on master and v0.3.6.

@quinnj
Copy link
Member

quinnj commented Nov 3, 2015

Saw this this morning:

julia> methods(append!)
# 10 methods for generic function "append!":
append!(A::Array{Bool,1}, items::BitArray{1}) at bitarray.jl:476
append!{T}(a::Array{T,1}, items::AbstractArray{T,1}) at array.jl:445
append!(B::BitArray{1}, items::BitArray{1}) at bitarray.jl:458
append!(B::BitArray{1}, items::AbstractArray{Bool,1}) at bitarray.jl:475
append!Error showing value of type MethodTable:
ERROR: type TypeConstructor has no field name
 in show at show.jl:105
 in print at strings/io.jl:8
 in print_to_string at strings/io.jl:36
 in argtype_decl at methodshow.jl:26
 in arg_decl_parts at methodshow.jl:38
 in show at methodshow.jl:44
 in show_method_table at methodshow.jl:69
 in show at methodshow.jl:82
 in anonymous at show.jl:1278
 in with_output_limit at /Users/jacobquinn/julia4/lib/julia/sys.dylib
 in showlimited at show.jl:1277
 in writemime at replutil.jl:4
 in display at REPL.jl:114
 in display at REPL.jl:117
 in display at multimedia.jl:151
 in print_response at REPL.jl:134
 in print_response at REPL.jl:121
 in anonymous at REPL.jl:624
 in run_interface at /Users/jacobquinn/julia4/lib/julia/sys.dylib
 in run_frontend at /Users/jacobquinn/julia4/lib/julia/sys.dylib
 in run_repl at /Users/jacobquinn/julia4/lib/julia/sys.dylib
 in _start at /Users/jacobquinn/julia4/lib/julia/sys.dylib

julia> versioninfo()
Julia Version 0.4.0
Commit 0ff703b* (2015-10-08 06:20 UTC)
Platform Info:
  System: Darwin (x86_64-apple-darwin13.4.0)
  CPU: Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

@quinnj quinnj reopened this Nov 3, 2015
@jakebolewski
Copy link
Member

This is fixed at least on latest master and v0.4.1.

@quinnj
Copy link
Member

quinnj commented Nov 3, 2015

cool, i thought I had seen some stuff going around on it.

@yuyichao
Copy link
Contributor Author

yuyichao commented Nov 6, 2015

@jakebolewski Do you know which commit/PR fixes this? The original issue was really sensitive to a number of things so I imagine minor tweak of random stuff can easily hide it. Ref #13306

yuyichao added a commit to yuyichao/explore that referenced this issue Nov 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

5 participants