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

BUG: strange error when using methods function #8163

Closed
sglyon opened this issue Aug 27, 2014 · 5 comments
Closed

BUG: strange error when using methods function #8163

sglyon opened this issue Aug 27, 2014 · 5 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@sglyon
Copy link
Contributor

sglyon commented Aug 27, 2014

Consider this very dumb example:

julia> g(x, y) = println("$(typeof(x))\t$(typeof(y))")
g (generic function with 1 method)

julia> g(1.0, 2)
Float64 Int64

julia> methods(g)
#1 method for generic function "g":
g(x,y) at none:1

julia> g(x::Vector, y::Real) = println("Vector and Real")
g (generic function with 2 methods)

julia> g([1.0], 2.0)   # so we know it works
Vector and Real

julia> methods(g)
#2 methods for generic function "g":
gError showing value of type MethodTable:
ERROR: type DataType has no field body
 in show at show.jl:80 (repeats 2 times)
 in print_to_string at ./string.jl:24
 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:61
 in show at methodshow.jl:74
 in anonymous at show.jl:1107
 in with_output_limit at ./show.jl:1084
 in showlimited at show.jl:1106
 in writemime at replutil.jl:2
 in display at REPL.jl:118
 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:587
 in run_interface at ./LineEdit.jl:1377
 in run_interface at /usr/local/julia/usr/lib/julia/sys.dylib
 in run_frontend at ./REPL.jl:819
 in run_repl at ./REPL.jl:170
 in _start at ./client.jl:399
 in _start at /usr/local/julia/usr/lib/julia/sys.dylib

Any idea why this is happening?

@stevengj
Copy link
Member

I ran into this earlier today. The error originates in:

show(io::IO, x::TypeConstructor) = show(io, x.body)

I'm not actually sure what TypeConstructor is, but the odd thing is that sometimes it works, depending on exactly what order I initialize things. Also, inserting a dump(x) into this method seems to indicate that x.body exists.

@JeffBezanson, isn't TypeConstructor some kind of internal magic? How should we print it if it is encountered in a method table?

@sglyon sglyon closed this as completed Aug 27, 2014
@sglyon sglyon reopened this Aug 27, 2014
@vtjnash
Copy link
Member

vtjnash commented Aug 28, 2014

I think I usually see TypeConstructors show up in conjunction with typealiases:

julia> AbstractVector|>typeof
TypeConstructor

@stevengj
Copy link
Member

And yet AbstractVector.body is defined and gives AbstractArray{T,1}.

@stevengj
Copy link
Member

The exception message above makes it seem like the TypeConstructor got converted to a DataType somehow; is there some kind of race condition here?

@vtjnash
Copy link
Member

vtjnash commented Nov 3, 2015

should now be fixed by bd7d3f5

@vtjnash vtjnash closed this as completed Nov 3, 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

4 participants