Skip to content

current_scope is recommended by an error message but inaccessible. #54178

@LilithHafner

Description

@LilithHafner

This is not a great UX:

julia> t = Task(() -> 4)
Task (runnable) @0x0000ffff6826d370

julia> t.scope
ERROR: Querying `scope` is disallowed. Use `current_scope` instead.
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] getproperty(t::Task, field::Symbol)
   @ Base ./task.jl:184
 [3] top-level scope
   @ REPL[65]:1

julia> current_scope
ERROR: UndefVarError: `current_scope` not defined in `Main`
Suggestion: check for spelling errors or missing imports.

julia> t.current_scope
ERROR: type Task has no field current_scope
Stacktrace:
 [1] getproperty(t::Task, field::Symbol)
   @ Base ./task.jl:186
 [2] top-level scope
   @ REPL[67]:1

julia> Base.current_scope
ERROR: UndefVarError: `current_scope` not defined in `Base`
Suggestion: check for spelling errors or missing imports.
Stacktrace:
 [1] getproperty(x::Module, f::Symbol)
   @ Base ./Base.jl:42
 [2] top-level scope
   @ REPL[68]:1

help?> current_scope
search: current_task current_exceptions

Couldn't find current_scope
Perhaps you meant current_task
  No documentation found.

  Binding current_scope does not exist.

julia> Core.current_scope
current_scope (built-in function)

error("Querying `scope` is disallowed. Use `current_scope` instead.")

Either the error should mention that the function is internal, or it should specify how to get a public handle on that function.

The error & hint was added in #52309
cc @Keno

Metadata

Metadata

Assignees

No one assigned

    Labels

    error messagesBetter, more actionable error messages

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions