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

Some type piracy in Lazy.jl #86

Open
rdeits opened this issue Jul 16, 2018 · 1 comment
Open

Some type piracy in Lazy.jl #86

rdeits opened this issue Jul 16, 2018 · 1 comment

Comments

@rdeits
Copy link

rdeits commented Jul 16, 2018

I was debugging what I thought was a problem with Interact and Widgets.jl, but it turned out to be some subtle type piracy coming from Lazy.jl. This line: https://github.com/MikeInnes/Lazy.jl/blob/db5a0eb044769d303a58c6582b7205b12e7257ab/src/liblazy.jl

overloads Base.map(f::Function) (since the ls... argument can be empty), which is classic type piracy. For example:

Without Lazy.jl:

julia> map(sin)
ERROR: MethodError: no method matching sin()
Closest candidates are:
  sin(::BigFloat) at mpfr.jl:637
  sin(::Complex{Float16}) at math.jl:951
  sin(::Float16) at math.jl:950
  ...
Stacktrace:
 [1] map(::Base.#sin) at ./abstractarray.jl:1935

With Lazy.jl loaded:

julia> using Lazy

julia> map(sin)
(Error showing value of type Lazy.LazyList:
ERROR: MethodError: no method matching sin()
Closest candidates are:
  sin(::BigFloat) at mpfr.jl:637
  sin(::Complex{Float16}) at math.jl:951
  sin(::Float16) at math.jl:950
  ...
Stacktrace:
 [1] (::Lazy.##59#60{Base.#sin,Tuple{}})() at /home/rdeits/.julia/v0.6/Lazy/src/Lazy.jl:93
 [2] realise!(::Lazy.LazyList) at /home/rdeits/.julia/v0.6/Lazy/src/Lazy.jl:79
 [3] realise(::Lazy.LazyList) at /home/rdeits/.julia/v0.6/Lazy/src/Lazy.jl:84
 [4] (::Lazy.##41#42{Lazy.LazyList,String,Int64})() at /home/rdeits/.julia/v0.6/Lazy/src/Lazy.jl:93
 [5] realise!(::Lazy.LazyList) at /home/rdeits/.julia/v0.6/Lazy/src/Lazy.jl:79
 [6] realise(::Lazy.LazyList) at /home/rdeits/.julia/v0.6/Lazy/src/Lazy.jl:87
 [7] (::Lazy.##37#38{Lazy.LazyList,Lazy.LinkedList})() at /home/rdeits/.julia/v0.6/Lazy/src/Lazy.jl:93
 [8] realise!(::Lazy.LazyList) at /home/rdeits/.julia/v0.6/Lazy/src/Lazy.jl:79
 [9] realise(::Lazy.LazyList) at /home/rdeits/.julia/v0.6/Lazy/src/Lazy.jl:87
 [10] any(::Base.#isempty, ::Tuple{Lazy.LazyList}) at ./reduce.jl:574
 [11] (::Lazy.##59#60{Lazy.##91#92{IOContext{Base.Terminals.TTYTerminal}},Tuple{Lazy.LazyList}})() at /home/rdeits/.julia/v0.6/Lazy/src/Lazy.jl:93
 [12] realise!(::Lazy.LazyList) at /home/rdeits/.julia/v0.6/Lazy/src/Lazy.jl:79
 [13] realise(::Lazy.LazyList) at /home/rdeits/.julia/v0.6/Lazy/src/Lazy.jl:87
 [14] dorun(::Lazy.LazyList) at /home/rdeits/.julia/v0.6/Lazy/src/tail.jl:123
 [15] show(::IOContext{Base.Terminals.TTYTerminal}, ::Lazy.LazyList) at /home/rdeits/.julia/v0.6/Lazy/src/Lazy.jl:149
 [16] display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::MIME{Symbol("text/plain")}, ::Lazy.LazyList) at ./REPL.jl:122
 [17] display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::Lazy.LazyList) at ./REPL.jl:125
 [18] display(::Lazy.LazyList) at ./multimedia.jl:218
 [19] eval(::Module, ::Any) at ./boot.jl:235
 [20] print_response(::Base.Terminals.TTYTerminal, ::Any, ::Void, ::Bool, ::Bool, ::Void) at ./REPL.jl:144
 [21] print_response(::Base.REPL.LineEditREPL, ::Any, ::Void, ::Bool, ::Bool) at ./REPL.jl:129
 [22] (::Base.REPL.#do_respond#16{Bool,Base.REPL.##26#36{Base.REPL.LineEditREPL,Base.REPL.REPLHistoryProvider},Base.REPL.LineEditREPL,Base.LineEdit.Prompt})(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at ./REPL.jl:646
@singularitti
Copy link

I just found the same problem! Though I think map(f) = f() is a bad design, this is still a type piracy. In fact, I do not even know I had Lazy.jl installed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants