From 48289cb63564becf0de7996020184c1772f8afa4 Mon Sep 17 00:00:00 2001 From: Lilith Orion Hafner Date: Sun, 21 Apr 2024 13:36:21 -0500 Subject: [PATCH 1/3] Better error message for task.scope --- base/task.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/base/task.jl b/base/task.jl index 7b19fc5f2a3d1..5758c63a9d687 100644 --- a/base/task.jl +++ b/base/task.jl @@ -180,7 +180,9 @@ end # TODO: this field name should be deprecated in 2.0 return t._isexception ? t.result : nothing elseif field === :scope - error("Querying `scope` is disallowed. Use `current_scope` instead.") + error(""" + Querying a Task's `scope` field is disallowed. + The private `Core.current_scope()` function is better, though still an implenetation detail.""") else return getfield(t, field) end From ef7f8b25b8eaf1b325d51bd21d98154652b55889 Mon Sep 17 00:00:00 2001 From: Lilith Orion Hafner Date: Sun, 21 Apr 2024 18:41:47 +0000 Subject: [PATCH 2/3] Update base/task.jl --- base/task.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/task.jl b/base/task.jl index 5758c63a9d687..f1608a41789d5 100644 --- a/base/task.jl +++ b/base/task.jl @@ -182,7 +182,7 @@ end elseif field === :scope error(""" Querying a Task's `scope` field is disallowed. - The private `Core.current_scope()` function is better, though still an implenetation detail.""") + The private `Core.current_scope()` function is better, though still an implementation detail.""") else return getfield(t, field) end From 6cfc417e445393e8e1705997ccb67a8359d33dea Mon Sep 17 00:00:00 2001 From: Lilith Orion Hafner Date: Mon, 22 Apr 2024 13:22:33 +0000 Subject: [PATCH 3/3] Update tests Intentionally use a different string literal syntax for better test robustness. --- test/channels.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/channels.jl b/test/channels.jl index 5e81f477126cd..f1642de1b7bec 100644 --- a/test/channels.jl +++ b/test/channels.jl @@ -642,6 +642,7 @@ end @testset "Task properties" begin f() = rand(2,2) t = Task(f) - @test_throws ErrorException("Querying `scope` is disallowed. Use `current_scope` instead.") t.scope + message = "Querying a Task's `scope` field is disallowed.\nThe private `Core.current_scope()` function is better, though still an implementation detail." + @test_throws ErrorException(message) t.scope @test t.state == :runnable end