Skip to content

Commit

Permalink
πŸŽƒ Fix #32
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp committed Mar 23, 2020
1 parent a381ce8 commit 2b45b88
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "Pluto"
uuid = "c3e4b0f8-55cb-11ea-2926-15256bba5781"
license = "MIT"
authors = ["Fons van der Plas <[email protected]>", "MikoΕ‚aj Bochenski <[email protected]>"]
version = "0.3.5"
version = "0.3.6"

[deps]
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
Expand Down
13 changes: 9 additions & 4 deletions src/react/ExploreExpression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function get_global_assignees(assignee_exprs, scopestate::ScopeState)
if ae.head == :(::)
will_assign_global(ae.args[1], scopestate) && push!(global_assignees, ae.args[1])
else
@warn "Unknown assignee expression"
@warn "Unknown assignee expression" ae
end
end
end
Expand Down Expand Up @@ -117,7 +117,7 @@ function explore!(ex::Expr, scopestate::ScopeState)::SymbolsState
elseif isa(ex.args[1], Expr)
if ex.args[1].head == :tuple
# (x, y) = (1, 23)
ex.args[1].args
filter(s -> s isa Symbol, ex.args[1].args)
elseif ex.args[1].head == :(::)
# TODO: type is referenced
[ex.args[1].args[1]]
Expand All @@ -134,9 +134,14 @@ function explore!(ex::Expr, scopestate::ScopeState)::SymbolsState
# function f(x, y) x + y end
return explore!(Expr(:function, ex.args...), scopestate)
else
@warn "unknow use of =. Assignee is unrecognised."
@warn "unknow use of =. Assignee is unrecognised." ex.args[1]
[]
end
else
# When you assign to a datatype like Int, String, or anything bad like that
# e.g. 1 = 2
# This is parsable code, so we have to treat it
[]
end
val = ex.args[2]

Expand Down Expand Up @@ -363,7 +368,7 @@ function explore!(ex::Expr, scopestate::ScopeState)::SymbolsState
end


function compute_symbolreferences(ex)
function compute_symbolreferences(ex)
explore!(ex, ScopeState(true, Set{Symbol}(), Set{Symbol}()))
end

Expand Down
28 changes: 16 additions & 12 deletions src/webserver/NotebookServer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ function flushclient(client)
return false
end
end
catch e
@warn "Failed to write to WebSocket of $(client.id) " e
catch ex
bt = stacktrace(catch_backtrace())
@warn "Failed to write to WebSocket of $(client.id) " exception=(ex,bt)
return false
end
end
Expand Down Expand Up @@ -171,26 +172,29 @@ function run(port = 1234, launchbrowser = false)
@warn "Message of type $(messagetype) not recognised"
end
end
catch e
if e isa InterruptException
rethrow(e)
elseif e isa HTTP.WebSockets.WebSocketError
catch ex
if ex isa InterruptException
rethrow(ex)
elseif ex isa HTTP.WebSockets.WebSocketError
# that's fine!
elseif e isa InexactError
elseif ex isa InexactError
# that's fine! this is a (fixed) HTTP.jl bug: https://github.com/JuliaWeb/HTTP.jl/issues/471
# TODO: remove this switch
else
bt = stacktrace(catch_backtrace())
@warn "Reading WebSocket client stream failed for unknown reason:" e bt
@warn "Reading WebSocket client stream failed for unknown reason:" exception=(ex,bt)
end
end
end
end
catch e
if e isa InterruptException
rethrow(e)
catch ex
if ex isa InterruptException
rethrow(ex)
elseif ex isa ArgumentError && occursin("stream is closed", ex.msg)
# that's fine!
else
@info "HTTP upgrade failed, should be fine" e
bt = stacktrace(catch_backtrace())
@warn "HTTP upgrade failed for unknown reason" exception=(ex,bt)
end
end
else
Expand Down
2 changes: 2 additions & 0 deletions test/ExploreExpression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ end
@test testee(:(x = let r = 1; r + r end), [:+], [:x])
@test testee(:(begin let r = 1; r + r end; r = 2 end), [:+], [:r])
@test testee(:(a, b = 1, 2), [], [:a, :b])
@test testee(:((a, b) = 1, 2), [], [:a, :b])
@test testee(:((a[1], b.r) = (1, 2)), [], [])
@test testee(:((k = 2; 123)), [], [:k])
@test testee(:((a = 1; b = a + 1)), [:+], [:a, :b])
@test testee(:(let k = 2; 123 end), [], [])
Expand Down
13 changes: 13 additions & 0 deletions test/React.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ import Pluto: Notebook, Client, run_reactive!,fakeclient, createcell_fromcode,
@test notebook.cells[1].output == notebook.cells[2].output
end

@testset "Bad code" begin
notebook = Notebook(joinpath(tempdir(), "test.jl"), [
createcell_fromcode("a"),
createcell_fromcode("1 = 2")
])
fakeclient.connected_notebook = notebook

@test_nowarn run_reactive!(fakeclient, notebook, notebook.cells[1])
@test_nowarn run_reactive!(fakeclient, notebook, notebook.cells[2])
@test notebook.cells[1].errormessage !== nothing
@test notebook.cells[2].errormessage !== nothing
end

@testset "Cyclic" begin
notebook = Notebook(joinpath(tempdir(), "test.jl"), [
createcell_fromcode("x = y"),
Expand Down

3 comments on commit 2b45b88

@fonsp
Copy link
Owner Author

@fonsp fonsp commented on 2b45b88 Mar 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/11421

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.6 -m "<description of version>" 2b45b88335a102e6a9c98b8fbbf61a9ec71dbf3d
git push origin v0.3.6

@fonsp
Copy link
Owner Author

@fonsp fonsp commented on 2b45b88 Mar 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolves #32

Please sign in to comment.