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

Reactivity breaks with a simple function definition #826

Closed
yurivish opened this issue Jan 6, 2021 · 1 comment · Fixed by #885
Closed

Reactivity breaks with a simple function definition #826

yurivish opened this issue Jan 6, 2021 · 1 comment · Fixed by #885
Labels
bug Something isn't working expression explorer Figuring out assignments and references in a cell

Comments

@yurivish
Copy link

yurivish commented Jan 6, 2021

Creating the following three cells in order illustrates the issue:

image

Once bc is defined, the test cell continues to say that bc is undefined.

What seems to be happening is that

bc(f) = (args...) -> f.(args...)

is not able to be be parsed by Pluto's expression parser.

Here is the full error and stack trace:


┌ Error: Unknown lambda type
└ @ Pluto.ExpressionExplorer ~/.julia/packages/Pluto/luIaC/src/analysis/ExpressionExplorer.jl:513
┌ Error: Expression explorer failed on:
│   ex =
│    :($(Expr(:toplevel, :(#= /Users/yurivish/.julia/pluto_notebooks/Exciting notebook.jl#==#15f27de0-504d-11eb-12b5-a93ae8f96c01:1 =#), :(bc(f) = begin
│              #= /Users/yurivish/.julia/pluto_notebooks/Exciting notebook.jl#==#15f27de0-504d-11eb-12b5-a93ae8f96c01:1 =#
│              args...->begin
│                      #= /Users/yurivish/.julia/pluto_notebooks/Exciting notebook.jl#==#15f27de0-504d-11eb-12b5-a93ae8f96c01:1 =#
│                      f.(args...)
│                  end
│          end))))
└ @ Pluto.ExpressionExplorer ~/.julia/packages/Pluto/luIaC/src/analysis/ExpressionExplorer.jl:888
MethodError: no method matching iterate(::Nothing)
Closest candidates are:
  iterate(::Pkg.Resolve.NodePerm, ::Any...) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Pkg/src/Resolve/maxsum.jl:228
  iterate(::Test.GenericString) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Test/src/Test.jl:1589
  iterate(::Test.GenericString, ::Integer) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Test/src/Test.jl:1589
  ...
Stacktrace:
 [1] explore!(::Expr, ::Pluto.ExpressionExplorer.ScopeState) at /Users/yurivish/.julia/packages/Pluto/luIaC/src/analysis/ExpressionExplorer.jl:516
 [2] (::Pluto.ExpressionExplorer.var"#32#39"{Pluto.ExpressionExplorer.ScopeState})(::Expr) at /Users/yurivish/.julia/packages/Pluto/luIaC/src/analysis/ExpressionExplorer.jl:649
 [3] MappingRF at ./reduce.jl:93 [inlined]
 [4] _foldl_impl(::Base.MappingRF{Pluto.ExpressionExplorer.var"#32#39"{Pluto.ExpressionExplorer.ScopeState},Base.BottomRF{typeof(union!)}}, ::Pluto.ExpressionExplorer.SymbolsState, ::Array{Any,1}) at ./reduce.jl:62
 [5] foldl_impl at ./reduce.jl:48 [inlined]
 [6] mapfoldl_impl(::Pluto.ExpressionExplorer.var"#32#39"{Pluto.ExpressionExplorer.ScopeState}, ::typeof(union!), ::NamedTuple{(:init,),Tuple{Pluto.ExpressionExplorer.SymbolsState}}, ::Array{Any,1}) at ./reduce.jl:44
 [7] mapfoldl(::Function, ::Function, ::Array{Any,1}; kw::Base.Iterators.Pairs{Symbol,Pluto.ExpressionExplorer.SymbolsState,Tuple{Symbol},NamedTuple{(:init,),Tuple{Pluto.ExpressionExplorer.SymbolsState}}}) at ./reduce.jl:160
 [8] explore!(::Expr, ::Pluto.ExpressionExplorer.ScopeState) at /Users/yurivish/.julia/packages/Pluto/luIaC/src/analysis/ExpressionExplorer.jl:649
 [9] (::Pluto.ExpressionExplorer.var"#32#39"{Pluto.ExpressionExplorer.ScopeState})(::Expr) at /Users/yurivish/.julia/packages/Pluto/luIaC/src/analysis/ExpressionExplorer.jl:649
 [10] MappingRF at ./reduce.jl:93 [inlined]
 [11] _foldl_impl(::Base.MappingRF{Pluto.ExpressionExplorer.var"#32#39"{Pluto.ExpressionExplorer.ScopeState},Base.BottomRF{typeof(union!)}}, ::Pluto.ExpressionExplorer.SymbolsState, ::Array{Any,1}) at ./reduce.jl:58
 [12] foldl_impl at ./reduce.jl:48 [inlined]
 [13] mapfoldl_impl(::Pluto.ExpressionExplorer.var"#32#39"{Pluto.ExpressionExplorer.ScopeState}, ::typeof(union!), ::NamedTuple{(:init,),Tuple{Pluto.ExpressionExplorer.SymbolsState}}, ::Array{Any,1}) at ./reduce.jl:44
 [14] mapfoldl(::Function, ::Function, ::Array{Any,1}; kw::Base.Iterators.Pairs{Symbol,Pluto.ExpressionExplorer.SymbolsState,Tuple{Symbol},NamedTuple{(:init,),Tuple{Pluto.ExpressionExplorer.SymbolsState}}}) at ./reduce.jl:160
 [15] explore!(::Expr, ::Pluto.ExpressionExplorer.ScopeState) at /Users/yurivish/.julia/packages/Pluto/luIaC/src/analysis/ExpressionExplorer.jl:649
 [16] explore!(::Expr, ::Pluto.ExpressionExplorer.ScopeState) at /Users/yurivish/.julia/packages/Pluto/luIaC/src/analysis/ExpressionExplorer.jl:453
 [17] explore!(::Expr, ::Pluto.ExpressionExplorer.ScopeState) at /Users/yurivish/.julia/packages/Pluto/luIaC/src/analysis/ExpressionExplorer.jl:302
 [18] (::Pluto.ExpressionExplorer.var"#32#39"{Pluto.ExpressionExplorer.ScopeState})(::Expr) at /Users/yurivish/.julia/packages/Pluto/luIaC/src/analysis/ExpressionExplorer.jl:649
 [19] MappingRF at ./reduce.jl:93 [inlined]
 [20] _foldl_impl(::Base.MappingRF{Pluto.ExpressionExplorer.var"#32#39"{Pluto.ExpressionExplorer.ScopeState},Base.BottomRF{typeof(union!)}}, ::Pluto.ExpressionExplorer.SymbolsState, ::Array{Any,1}) at ./reduce.jl:62
 [21] foldl_impl at ./reduce.jl:48 [inlined]
 [22] mapfoldl_impl(::Pluto.ExpressionExplorer.var"#32#39"{Pluto.ExpressionExplorer.ScopeState}, ::typeof(union!), ::NamedTuple{(:init,),Tuple{Pluto.ExpressionExplorer.SymbolsState}}, ::Array{Any,1}) at ./reduce.jl:44
 [23] mapfoldl(::Function, ::Function, ::Array{Any,1}; kw::Base.Iterators.Pairs{Symbol,Pluto.ExpressionExplorer.SymbolsState,Tuple{Symbol},NamedTuple{(:init,),Tuple{Pluto.ExpressionExplorer.SymbolsState}}}) at ./reduce.jl:160
 [24] explore!(::Expr, ::Pluto.ExpressionExplorer.ScopeState) at /Users/yurivish/.julia/packages/Pluto/luIaC/src/analysis/ExpressionExplorer.jl:649
 [25] compute_symbolreferences(::Expr) at /Users/yurivish/.julia/packages/Pluto/luIaC/src/analysis/ExpressionExplorer.jl:870
 [26] try_compute_symbolreferences(::Expr) at /Users/yurivish/.julia/packages/Pluto/luIaC/src/analysis/ExpressionExplorer.jl:886
 [27] |> at ./operators.jl:834 [inlined]
 [28] #66 at ./none:0 [inlined]
 [29] iterate at ./generator.jl:47 [inlined]
 [30] Dict{Pluto.Cell,Pluto.ReactiveNode}(::Base.Generator{Array{Pluto.Cell,1},Pluto.var"#66#67"}) at ./dict.jl:102
 [31] dict_with_eltype at ./abstractdict.jl:531 [inlined]
 [32] dict_with_eltype at ./abstractdict.jl:538 [inlined]
 [33] Dict(::Base.Generator{Array{Pluto.Cell,1},Pluto.var"#66#67"}) at ./dict.jl:128
 [34] updated_topology at /Users/yurivish/.julia/packages/Pluto/luIaC/src/evaluation/Update.jl:20 [inlined]
 [35] update_save_run!(::Pluto.ServerSession, ::Pluto.Notebook, ::Array{Pluto.Cell,1}; save::Bool, run_async::Bool, prerender_text::Bool, kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /Users/yurivish/.julia/packages/Pluto/luIaC/src/evaluation/Run.jl:129
 [36] (::Pluto.var"#147#149")(::Pluto.ServerSession, ::Dict{Any,Any}, ::Pluto.Notebook, ::Pluto.Cell; initiator::Pluto.Initiator) at /Users/yurivish/.julia/packages/Pluto/luIaC/src/webserver/Dynamic.jl:94
 [37] process_ws_message(::Pluto.ServerSession, ::Dict{Any,Any}, ::HTTP.WebSockets.WebSocket{HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}) at /Users/yurivish/.julia/packages/Pluto/luIaC/src/webserver/WebServer.jl:357
 [38] (::Pluto.var"#215#225"{Pluto.ServerSession,Base.RefValue{Function}})(::HTTP.WebSockets.WebSocket{HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}) at /Users/yurivish/.julia/packages/Pluto/luIaC/src/webserver/WebServer.jl:160
 [39] upgrade(::Pluto.var"#215#225"{Pluto.ServerSession,Base.RefValue{Function}}, ::HTTP.Streams.Stream{HTTP.Messages.Request,HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}; binary::Bool) at /Users/yurivish/.julia/packages/HTTP/IAI92/src/WebSockets.jl:160
 [40] upgrade at /Users/yurivish/.julia/packages/HTTP/IAI92/src/WebSockets.jl:142 [inlined]
 [41] (::Pluto.var"#214#224"{Pluto.ServerSession,HTTP.Handlers.Router{Symbol("##253")},Base.RefValue{Function}})(::HTTP.Streams.Stream{HTTP.Messages.Request,HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}) at /Users/yurivish/.julia/packages/Pluto/luIaC/src/webserver/WebServer.jl:147
 [42] handle at /Users/yurivish/.julia/packages/HTTP/IAI92/src/Handlers.jl:269 [inlined]
 [43] #4 at /Users/yurivish/.julia/packages/HTTP/IAI92/src/Handlers.jl:345 [inlined]
 [44] macro expansion at /Users/yurivish/.julia/packages/HTTP/IAI92/src/Servers.jl:367 [inlined]
 [45] (::HTTP.Servers.var"#13#14"{HTTP.Handlers.var"#4#5"{HTTP.Handlers.StreamHandlerFunction{Pluto.var"#214#224"{Pluto.ServerSession,HTTP.Handlers.Router{Symbol("##253")},Base.RefValue{Function}}}},HTTP.ConnectionPool.Transaction{Sockets.TCPSocket},HTTP.Streams.Stream{HTTP.Messages.Request,HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}})() at ./task.jl:356

The Pluto version is Pluto v0.12.18 and the Julia version is:

julia> versioninfo()
Julia Version 1.5.3
Commit 788b2c77c1 (2020-11-09 13:37 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.7.0)
  CPU: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, skylake)
@yurivish yurivish changed the title Reactivity breaks with one particular function Reactivity breaks with a simple function definition Jan 6, 2021
@fonsp fonsp added bug Something isn't working expression explorer Figuring out assignments and references in a cell labels Jan 11, 2021
@fonsp
Copy link
Owner

fonsp commented Jan 30, 2021

I wrote a test, this one should pass after the fix:

# @test_broken testee(:(f = (args...) -> [args..., y]), [], [:f], [], [
# :anon => ([:y], [], [], [])
# ])
# @test_broken testee(:(f = (x, args...; kwargs...) -> [x, y, args..., kwargs...]), [], [:f], [], [
# :anon => ([:y], [], [], [])
# ])

Instructions are at the top of that file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working expression explorer Figuring out assignments and references in a cell
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants