Skip to content

Commit

Permalink
fix incorrect error path in schedule (#31812)
Browse files Browse the repository at this point in the history
(cherry picked from commit 4c30076)
  • Loading branch information
JeffBezanson authored and KristofferC committed May 9, 2019
1 parent 7d0baab commit c3dc4ce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/task.jl
Original file line number Diff line number Diff line change
Expand Up @@ -457,12 +457,12 @@ true
"""
function schedule(t::Task, @nospecialize(arg); error=false)
# schedule a task to be (re)started with the given value or exception
t.state == :runnable || error("schedule: Task not runnable")
t.state == :runnable || Base.error("schedule: Task not runnable")
if error
t.queue === nothing || Base.list_deletefirst!(t.queue, t)
t.exception = arg
else
t.queue === nothing || error("schedule: Task not runnable")
t.queue === nothing || Base.error("schedule: Task not runnable")
t.result = arg
end
enq_work(t)
Expand Down
6 changes: 6 additions & 0 deletions test/channels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -389,3 +389,9 @@ let a = Ref(0)
GC.gc()
@test a[] == 1
end

# trying to `schedule` a finished task
let t = @async nothing
wait(t)
@test_throws ErrorException("schedule: Task not runnable") schedule(t, nothing)
end

0 comments on commit c3dc4ce

Please sign in to comment.